feat(sync): add delay sync for growing files#39
Open
CrooLyyCheck wants to merge 1 commit intocloudreve:mainfrom
Open
feat(sync): add delay sync for growing files#39CrooLyyCheck wants to merge 1 commit intocloudreve:mainfrom
CrooLyyCheck wants to merge 1 commit intocloudreve:mainfrom
Conversation
Add a delay sync setting so uploads wait until files stop changing, preventing partial uploads for growing files like in-progress video recordings. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Note⚠️
Hi, I just vibe-coded the whole thing, almost end-to-end, including cloning the repo, forking it, and pushing this PR. So please don’t take this PR too seriously, only like a feature request/proof of concept. I don’t have much experience writing code on my own. I only have a basic understanding of what some code fragments do. Video without and with this feature enabled: https://youtu.be/iApYUjTPDPA
Problem
When large media files (for example, a 4-minute screen recording) are saved directly inside a synced folder, the
.mp4file keeps growing while recording is still in progress. The current sync flow may enqueue upload too early, which can result in uploading an incomplete file revision, unnecessary re-uploads, and wasted bandwidth.Root Cause
Upload tasks are triggered on local file create/modify events. For continuously written files, these events happen before the producing process closes the file and before content stabilizes.
What This PR Introduces
1) New user-facing setting (General -> Experimental features)
off10s30s1min2min5minSync task wait until file stop changing.2) Persisted configuration and Tauri command wiring
sync_delay_secondsinAppConfig.0(feature disabled by default, preserving current behavior).ConfigManager.get_general_settingspayload withsync_delay_seconds.set_sync_delay_seconds.3) Upload queue stabilization logic
Before executing an upload task, queue now:
ConfigManager.0, proceeds immediately (backward-compatible behavior).0, waits until file remains unchanged for the configured window.4) Performance safeguards
To minimize machine load while waiting:
1sfor short delays2sfor medium delays3sfor long delays5sduring wait.Why This Solves the Problem
For long-running writers (screen recording, video export, etc.), upload starts only after the file has stopped changing for the selected stability window. This prevents premature upload of in-progress files and reduces unnecessary network and sync churn.
Backward Compatibility
off(sync_delay_seconds = 0).Scope of Changes
Test Plan
Delay syncto30s..mp4directly inside synced folder.offand verify immediate upload behavior is unchanged.