Skip to content

Commit

Permalink
Set SYNC_CACHE_AGE to 0 to disable auto sync. (stuartcryan#50)
Browse files Browse the repository at this point in the history
* Set SYNC_CACHE_AGE to 0 to disable auto sync.
  • Loading branch information
blacs30 authored Oct 29, 2020
1 parent 1d98eb8 commit 4c4b5ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bitwarden.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 8 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4c4b5ed

Please sign in to comment.