Skip to content

feat: add cloud download quota display and local session cache#60

Open
lnzx wants to merge 6 commits into52funny:masterfrom
lnzx:master
Open

feat: add cloud download quota display and local session cache#60
lnzx wants to merge 6 commits into52funny:masterfrom
lnzx:master

Conversation

@lnzx
Copy link

@lnzx lnzx commented Mar 18, 2026

1. display cloud download quota

  • Add CloudDownload field to Quotas struct
  • Add Remaining() method to Quota struct to calculate remaining quota
  • GetQuota() now returns full QuotaMessage including Quotas
  • Display cloud download quota (total/used/remaining) in quota command output

Output Example

$ ./pikpakcli quota
Storage:
total used
6442450944 0

cloud download:
total used remaining
5 5 0

$ ./pikpakcli quota -H
Storage:
total used
6.0GB 0B

cloud download:
total used remaining
5 5 0

image

2. Session Cache

Every command invocation triggers a full login request, including the
captcha/init endpoint. This is slow and risks account suspension due
to frequent authentication requests.

Add local session cache in ~/.config/pikpakcli/session_{md5}.json:

  • Reuse valid access_token directly
  • Use refresh_token to renew expired access_token
  • Fall back to full login only when refresh_token is also invalid

Session file is named by account md5 hash to support multiple accounts.

Changes

  • session.go: add sessionFile, saveSession, loadSession,
    isTokenExpired
  • pikpak.go: refactor Login() to check local session first,
    extract original login logic to login()
  • refresh_token.go: replace p.Login() with p.login() to avoid
    circular calls

@lnzx lnzx changed the title feat: add cloud download quota display feat: add cloud download quota display and local session cache Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant