diff --git a/bitwarden.go b/bitwarden.go index be5cff5..a4910f9 100644 --- a/bitwarden.go +++ b/bitwarden.go @@ -106,7 +106,7 @@ func runSync(force bool, last bool) { getItems() } fmt.Println(output) - err = wf.Cache.Store(SYNC_CACH_NAME, []byte(string("sync-cache"))) + err = wf.Cache.Store(SYNC_CACHE_NAME, []byte(string("sync-cache"))) if err != nil { log.Println(err) } @@ -200,7 +200,7 @@ func runGetItem() { } totp := opts.Totp attachment := opts.Attachment - // first check if Bitwarden is logged in and locked + // first check if Bitwarden is logged in or locked loginErr, unlockErr := BitwardenAuthChecks() if loginErr != nil { searchAlfred(fmt.Sprintf("%s login", conf.BwauthKeyword)) diff --git a/cli.go b/cli.go index 1012e2f..9637bfc 100644 --- a/cli.go +++ b/cli.go @@ -517,7 +517,7 @@ func runSearch(folderSearch bool, itemId string) { } // Check the sync cache, if it expired or doesn't exist do a sync. - if wf.Cache.Expired(SYNC_CACH_NAME, conf.SyncMaxCacheAge) || !wf.Cache.Exists(SYNC_CACH_NAME) { + if (conf.SyncCacheAge != 0 && wf.Cache.Expired(SYNC_CACHE_NAME, conf.SyncMaxCacheAge)) || !wf.Cache.Exists(SYNC_CACHE_NAME) { if !wf.IsRunning("sync") { cmd := exec.Command(os.Args[0], "-sync", "-force") log.Println("Sync cmd: ", cmd) diff --git a/main.go b/main.go index 75d3bcc..7cfd6b6 100644 --- a/main.go +++ b/main.go @@ -20,23 +20,19 @@ import ( ) const ( - issueTrackerURL = "https://github.com/blacs30/bitwarden-alfred-workflow/issues" - forumThreadURL = "https://www.alfredforum.com/topic/11705-bitwarden-cli-get-passwords-username-and-totp-from-bitwarden/" - repo = "blacs30/bitwarden-alfred-workflow" -) - -var ( - wf *aw.Workflow - //BwExec = "" - //BWAUTH_KEYWORD = "" - //BWCONF_KEYWORD = "" - //BW_KEYWORD = "" + issueTrackerURL = "https://github.com/blacs30/bitwarden-alfred-workflow/issues" + forumThreadURL = "https://www.alfredforum.com/topic/11705-bitwarden-cli-get-passwords-username-and-totp-from-bitwarden/" + repo = "blacs30/bitwarden-alfred-workflow" CACHE_NAME = "bw-items" ICON_CACHE_NAME = "icon-items" FOLDER_CACHE_NAME = "bw-items-folders" WORKFLOW_NAME = "bitwarden-alfred-workflow" AUTO_FETCH_CACHE = "auto-fetch" - SYNC_CACH_NAME = "sync-cache" + SYNC_CACHE_NAME = "sync-cache" +) + +var ( + wf *aw.Workflow ) func init() {