macxred / cashctrl_api

Python client for the CashCtrl REST API
MIT License
0 stars 0 forks source link

Sketch to Mirror Files #11

Closed lasuk closed 4 months ago

lasuk commented 4 months ago

Sketch for CashCtrlAPIClient.mirror_files()

CashCtrlAPIClient.mirror_files(root: (str | Path))
Param root: path of the local directory to mirror
  1. Preparation: get list of local_files and remote_files as pd.DataFrame

  2. Delete remote files

    to_delete = ~remote_files['path'].isin(local_files['path'])
    Delete all remote_files.loc[to_delete, 'id'] on API
    
    remote_files = remote_files.loc[~ to_delete,:]
  3. Sync categories between local_files and remaining remote_files

  4. Upload new or modified files

    Probably fetch category list again to ensure newly created categories are present.
    to_upload = ~remote_files['path'].isin(local_files['path']) | locally modified later than remote modified
    Upload all local_files.loc[to_upload, 'path']
lasuk commented 4 months ago

Implemented as CashCtrlClient.mirror_files()