(這是個 PoC 用於表示實現思路)避免在 too many requests 或者 network unreachable 的時候 丟失節點信息:使得 geph4-client 只有在成功從 binder 獲取到登錄信息的時候,才會覆蓋更新本地緩存 ~/.config/geph4-credentials/ #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
現在的 sync --force 的邏輯很不合理,是先刪除了 緩存目錄,然後連接 binder 更新。所以如果連接不上 binder 的時候就會 丟失上一次 sync 的信息
簡單來說,這個例子是先創建一個新的目錄來表示 “最新狀態”,然後只有在 geph4-client sync 命令執行成功時才會把這個 state 更新到 原本的儲存位置。
這樣一旦互聯網斷開、用戶頻繁請求導致 429,或者是因爲 binder 下線 導致無法更新的時候,那麼不會改動上一次保存的 json 文件 ,所以用戶可以嘗試使用最後一次 sync 得到的信息