Skip to content

Feature: Add Subfolder Strategy for Automatic Uploads#56

Open
PhilippThaler wants to merge 1 commit intoopencloud-eu:mainfrom
PhilippThaler:feature/upload-subfolders-by-date
Open

Feature: Add Subfolder Strategy for Automatic Uploads#56
PhilippThaler wants to merge 1 commit intoopencloud-eu:mainfrom
PhilippThaler:feature/upload-subfolders-by-date

Conversation

@PhilippThaler
Copy link
Copy Markdown

Feature: Add Subfolder Strategy for Automatic Uploads

Based on #46

What does this PR do?

This PR introduces a new feature that allows users to automatically organize their camera uploads into subfolders based on the date the picture or video was taken. Users can choose to create subfolders by:

  • Year (/2025/)
  • Year and Month (/2025/11/)
  • Year, Month, and Day (/2025/11/09/)

This helps users keep their cloud storage tidy and makes it easier to browse through photos from specific dates.

How is this implemented?

  • Added UseSubfoldersBehaviour Enum:
    • A new enum was added to FolderBackUpConfiguration.kt to represent the different subfolder options (NONE, YEAR, YEAR_MONTH, YEAR_MONTH_DAY).
  • Updated AutomaticUploadsWorker:
    • Create the function buildUploadPath to construct the remote path dynamically based on the selected UseSubfoldersBehaviour and the file's last modified date.
  • Database and Migrations:
    • The FolderBackUpEntity and the corresponding database migration (MIGRATION_43_44) were updated to include the new useSubfoldersBehaviour field.

How to test this?

  1. Navigate to Settings > Automatic Uploads for either pictures or videos.
  2. Select a new option under the "Upload to Subfolders" preference.
  3. Add a new image/video to the source folder on your device.
  4. Wait for the automatic upload worker to run (or trigger it manually).
  5. Verify that the file is uploaded to the correct subfolder in your cloud account.
  6. Repeat for all subfolder options.

Screenshots

Screenshot_2025-11-09-23-34-29-553_eu opencloud android debug_1
Screenshot_2025-11-09-23-34-41-512_eu opencloud android debug_1

@PhilippThaler PhilippThaler force-pushed the feature/upload-subfolders-by-date branch 3 times, most recently from 58a9e8a to fd65b96 Compare November 9, 2025 22:53
@PhilippThaler PhilippThaler marked this pull request as ready for review November 9, 2025 22:54
@RalphHeger
Copy link
Copy Markdown

Heavily waiting for that one :-)

@christinloehner
Copy link
Copy Markdown

this thing is soooo missing! Waiting for this as fu** :-)

@guruz
Copy link
Copy Markdown
Contributor

guruz commented Mar 27, 2026

Thank you for updating the PR.
See the build/detekt results ^

@PhilippThaler
Copy link
Copy Markdown
Author

Thanks for pointing that out. It was a simple typo that tripped up detekt. Fixed and verified.

@zerox80
Copy link
Copy Markdown
Contributor

zerox80 commented Apr 25, 2026

hi, ill start reviewing this

@zerox80
Copy link
Copy Markdown
Contributor

zerox80 commented Apr 25, 2026

Hey, looked through the changes and found a couple issues:

MIGRATION_43_44 conflicts with the existing AutoMigration

There's already an AutoMigration(from = 43, to = 44) on main - it adds the password_policy_* columns to the capabilities table. This PR adds a manual MIGRATION_43_44 for the same version pair. Room will use the manual migration and skip the auto one, which means the capabilities table changes get lost and the app crashes on upgrade for users on schema 43.

The migration should target 49->50 (current DB version is 49), not 43->44.

SQL syntax in Migration_44.kt

The DEFAULT clause produces DEFAULT NONE instead of DEFAULT 'NONE' — the string value needs quotes in SQL. But this whole file goes away if you fix the version anyway.

Legacy users get YEAR subfolders

Migration_34.kt sets useSubfoldersBehaviour = YEAR for existing users migrating from SharedPreferences. So existing camera upload users will start getting /CameraUpload/2026/ instead of /CameraUpload/. Might be intentional but worth confirming.

@PhilippThaler PhilippThaler force-pushed the feature/upload-subfolders-by-date branch 3 times, most recently from cb92357 to 780c49a Compare April 26, 2026 17:49
@PhilippThaler
Copy link
Copy Markdown
Author

Thanks for the review! All issues should be fixed now:

  1. MIGRATION_43_44 conflict — Removed the broken MIGRATION_43_44 entirely and replaced it with MIGRATION_49_50. The migration now uses PRAGMA table_info to check if the column already exists (for anyone who tested the broken migration), then adds it if not.

  2. SQL syntax — Fixed with proper quoting (DEFAULT 'NONE').

  3. Legacy users default — Changed from YEAR to NONE in CameraUploadsMigrationToRoom. Existing users shouldn't suddenly have their uploads uploaded to a year folder

Let me know if there's anything else!

@zerox80
Copy link
Copy Markdown
Contributor

zerox80 commented Apr 26, 2026

Thanks for the update, I took another look at the latest head (780c49a).

The Room migration issues from my earlier pass look fixed now. DB version is 50, the 49 -> 50 migration is registered, and the TEXT default is quoted as 'NONE'.

I don't see a critical blocker in the current diff. The one thing I would still add is a small test around AutomaticUploadsWorker's new date based path logic. Covering NONE, YEAR, YEAR_MONTH, and YEAR_MONTH_DAY with a fixed lastModified timestamp would make this easier to trust.

Small cleanup: the XML defaultValue is 'None' while the actual entry value is 'NONE'. That probably does not break the current flow, but matching it to 'NONE' would be cleaner.

@zerox80
Copy link
Copy Markdown
Contributor

zerox80 commented Apr 26, 2026

And please squash from 4c56aa2 to 780c49a (9 commits)

would appreciate it.

@PhilippThaler
Copy link
Copy Markdown
Author

PhilippThaler commented Apr 26, 2026

Changed the XML defaultValue and created AutoUploadPathBuilderTest.

The tests should work but the problem is that they won't compile because tests like "eu/opencloud/android/presentation/viewmodels/DrawerViewModelTest.kt are using kotlinx.coroutines.test.TestCoroutineDispatcher#pauseDispatcher() which is deprecated and gives compilation errors.
I think updating all those tests should happen in a different PR (#131)

squashed everything

@PhilippThaler PhilippThaler force-pushed the feature/upload-subfolders-by-date branch from 780c49a to 620f97d Compare April 26, 2026 20:11
@zerox80
Copy link
Copy Markdown
Contributor

zerox80 commented Apr 26, 2026

thank u

@guruz can u take a look here this PR is pretty old

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.

5 participants