Repository navigation
Conversation
Each asset now gets a dated path only when both the Auto Upload destination and its subfolders are enabled. Items backed by temporary files use the base folder, so they cannot inherit the previous asset’s dated path. A regression test covers selecting a folder while the subfolder preference is still enabled. Fixes nextcloud#4102 Assisted-by: AI Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the upload-destination fix, though the new regression test was not run in the reported environment.
No open issues 🎉
What changed in this PR
Fixes #4102 by keeping manual photo and video uploads in the selected folder when Auto Upload is disabled, even if its dated-subfolder preference remains enabled.
Changes:
- Uses dated paths only when both the Auto Upload destination and subfolders are enabled.
- Keeps temporary-file uploads in the base folder rather than inheriting a previous asset’s destination.
- Adds a regression test and registers it with the unit-test target.
The new test was not run in the reported environment.
| File | Description |
|---|---|
Tests/NextcloudUnitTests/NCUploadAssetsModelTests.swift |
Tests that a saved subfolder preference does not override the selected folder. |
Nextcloud.xcodeproj/project.pbxproj |
Adds the regression test to the unit-test target. |
iOSClient/Main/Create/Upload Assets/NCUploadAssetsModel.swift |
Corrects destination selection for assets and temporary files. |
Review effort: Balanced
marinofaggiana
left a comment
There was a problem hiding this comment.
Thanks a lot for tracking this down, @mvanhorn! The diagnosis is spot on: the "create subfolders" toggle is only visible when "use Auto Upload folder" is on, but its persisted value is still applied in save(), so a hidden true overrides the folder the user picked. Requiring both flags matches how the view and createMetadatasFolder already behave. 👍
A few small things before we merge:
1. Temp-file loop: the helper call is a no-op
With useAutoUploadSubFolder: false and granularityPath: baseServerUrl, manualUploadServerUrl always returns baseServerUrl. Could you just use it directly?
let metadata = await NCManageDatabaseCreateMetadata().createMetadataAsync(
fileName: fileName,
ocId: ocId,
serverUrl: baseServerUrl,
...Also, assets and tempAssets come from two separate initializers and are never mixed, so on master the temp loop never actually picked up a previous asset's dated path. Making it explicit with baseServerUrl is still a nice improvement, but the PR description and commit message overstate that part a bit.
2. Please extend the test
Right now only one branch of the condition is covered. Please also add:
- both flags on → returns the granularity path
- Auto Upload folder on, subfolders off → returns the base URL
Using a consistent value shape for baseServerUrl and granularityPath (both full URLs or both paths) would make the test easier to read. The @MainActor on the suite isn't needed for a pure static function.
3. (Optional) Simpler shape
The static helper with @autoclosure exists mainly to make this testable, which is fine. If you'd rather keep it inline, a plain if useAutoUploadFolder && useAutoUploadSubFolder { … } else { baseServerUrl } would read just as well. Up to you.
4. AI disclosure
The description says AI was used, but the AI checkbox is unticked and marked "N/A". Please tick it. Per the org-wide policy, the trailer should also name the tool and model, e.g. Assisted-by: AGENT_NAME:MODEL_VERSION, instead of just Assisted-by: AI.
Thanks again!
Temp-file items now pass baseServerUrl straight to the metadata, since the helper always returned it there. The tests cover all three flag combinations with one URL shape, and the suite drops @mainactor. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
|
Thanks @marinofaggiana. In 70cd1bf the temp-file loop passes |
Resolve the project.pbxproj conflict by keeping both the NCUploadAssetsModelTests entries and the new test and source files from master. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
|
Merged master into the branch in da60832; the only conflict was |
A manual photo or video upload could land in a dated Auto Upload subfolder even after the user turned off the Auto Upload destination and selected another folder. The save code chose the correct base folder, then replaced it with a dated Auto Upload path whenever the saved subfolder preference was enabled. That check ignored whether Auto Upload was the selected destination.
Each asset now gets a dated path only when both the Auto Upload destination and its subfolders are enabled. Items backed by temporary files now pass the base folder straight to their metadata; they never shared the PHAsset loop's path, so that part makes the destination explicit rather than fixing a second bug. Tests cover all three flag combinations of
manualUploadServerUrl.swift_testsran no tests because no Swift package owns the changed files.repo_lintran twice with no recorded output or exit status.A run with the ios NCUploadAssetsModel: change reverted gave no clear result, so no test is shown to catch this bug.
The tests in Tests/NextcloudUnitTests/NCUploadAssetsModelTests.swift did not run here: no test runner for it was available. Both changed files pass
swiftc -parse.🤖 AI (if applicable)
AI was used for assistance.
Fixes #4102