Skip to content

Refactor: Unified Auto Upload Architecture#129

Open
PhilippThaler wants to merge 14 commits intoopencloud-eu:mainfrom
PhilippThaler:feature/refactor-auto-uploads
Open

Refactor: Unified Auto Upload Architecture#129
PhilippThaler wants to merge 14 commits intoopencloud-eu:mainfrom
PhilippThaler:feature/refactor-auto-uploads

Conversation

@PhilippThaler
Copy link
Copy Markdown

Built upon #56 and based on #124
So there aren't that many changes if #56 is merged first

Summary

This PR is mostly about refactoring the background workers to use a unified upload architecture. Instead of having "Picture" and "Video" logic hardcoded everywhere, the background sync is now entirely driven by the configuration itself.
This gives us a much cleaner foundation so we can eventually support custom folders and other features for auto uploading in the future.
While creating this, I also fixed a few edge cases, I ran into where settings would overwrite each other, or where files would end up in the wrong folder if you changed your settings while waiting for Wi-Fi.

What changed

  • Unified the upload logic: The workers no longer care if a file is a picture or a video. They just look up the configuration and do what it says.
  • Moved the subfolder logic: I moved the buildUploadPath function from Feature: Add Subfolder Strategy for Automatic Uploads #56 into a shared helper (AutoUploadPathBuilder) so both the scanner and the actual upload worker can use it.
  • Calculate paths at the very last second: Before, the app locked in the upload path as soon as it found a new file. Now, it calculates the final path right before it hits the network. This means if a file is waiting for Wi-Fi and you change your destination folder in the settings, it will actually go to the new folder.
  • Fixed settings getting overwritten: The worker now fetches the latest settings right before saving its sync timestamp. This stops it from accidentally restoring old settings if you changed them while the worker was running.
  • Fixed picture/video mixups: Because we moved to a unified config system, I added a strict check on the config name. This stops the app from mixing up picture and video settings if they are both watching the exact same local folder (like /DCIM/Camera).

How to test

  1. Normal uploads still work (Regression)
    • Turn on auto-uploads with subfolders, take a pic/video, and make sure it still works exactly like it did in Feature: Add Subfolder Strategy for Automatic Uploads #56. The unified logic shouldn't break anything.
  2. Changing settings mid-upload
    • Turn on auto-uploads (Wi-Fi only) and turn off your Wi-Fi.
    • Take a picture/video so it gets queued up.
    • Go into the app settings and change the destination folder.
    • Turn Wi-Fi back on.
    • Verify: It should upload to the new folder, and the Uploads tab should update to show the new folder right as it starts.
  3. Picture/Video mixup fix
    • Set up both Picture and Video auto-uploads for the exact same local folder (e.g., /DCIM/Camera) but with different target folders on the server.
    • Trigger an auto-upload.
    • Verify: The picture and video configs should stay completely separate and not overwrite each other in the database anymore.

So this

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