Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for right media type in auto upload #13255

Conversation

JonasMayerDev
Copy link
Collaborator

@JonasMayerDev JonasMayerDev commented Jul 9, 2024

Fixes #13087, Fixes #13035, Fixes #12910.

To test this PR, have images and videos in the same folder, activate auto upload for videos OR images and put a new file of the opposite type in the folder. Without this PR it uploads the file regardless. With that PR it first checks if it is the correct type and then uploads.

Master -> Image gets upload even though only video folder is activated

Screen_recording_20240711_192320.webm

PR -> No images only videos get upload when only video folder is activated

WithPRDownscaled.webm
  • Tests written, or not not needed

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
@JonasMayerDev JonasMayerDev force-pushed the 13035-only-pictures-are-enabled-but-videos-also-auto-synced branch from 3db4443 to 700dd54 Compare July 9, 2024 15:10
Copy link
Collaborator

@alperozturk96 alperozturk96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto upload, not uploading to the correct path after configure.

f.mp4

How to Reproduce?

  1. Enable auto upload for new detected media folder
  2. InstantUpload folder will be used for auto upload
  3. Configure the auto upload path (e.g. MyFavFolder) for selected folder
  4. Still uploading to the InstantUpload folder

@@ -275,7 +277,11 @@ public void setExcludeHidden(boolean excludeHidden) {
}

public boolean containsFile(String filePath){
Copy link
Collaborator

@alperozturk96 alperozturk96 Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 public boolean containsFile(String filePath) {
        return filePath.contains(localPath);
    }

 public boolean isImageOrVideo(String filePath) {
        return (getType() == MediaFolderType.IMAGE && MimeTypeUtil.isImage(new File(filePath))) ||
                (getType() == MediaFolderType.VIDEO && MimeTypeUtil.isVideo(new File(filePath))) ||
                getType() == MediaFolderType.CUSTOM;
 }

It would be good to separate the logic because otherwise containsFile() doing two jobs and the name of the function will mislead us.

Why getType() == MediaFolderType.CUSTOM used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think containsFile is fitting since there are "video auto upload folders", "custom auto upload folders" and "image auto upload folders". To decide if the folder contains the file, it needs to know what type the files has to decide whether it belongs to a "video auto upload folders" or a "image auto upload folders" because both correspond to the same local folder. If the user customizes a custom folder, it should upload the files regardless of type since there is no differentiation between videos and images and everything belongs to one "auto upload folder"...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we know that this is the case and that is exactly why we need to separate it into two functions. Otherwise, we have to give such a long explanation.

The code should explain itself as much as possible, rather than us explaining it.

@JonasMayerDev
Copy link
Collaborator Author

Auto upload, not uploading to the correct path after configure.

f.mp4
How to Reproduce?

  1. Enable auto upload for new detected media folder
  2. InstantUpload folder will be used for auto upload
  3. Configure the auto upload path (e.g. MyFavFolder) for selected folder
  4. Still uploading to the InstantUpload folder

I think this is also an issue on master (could you pls test). When you activate auto upload and then afterward change the directory for upload, it already uploaded the files to the wrong directory. Only new files will be uploaded to the newly specified folder. To mitigate this, you can activate and change the path of the folder using the 3 dot menu in one go.

@alperozturk96
Copy link
Collaborator

Auto upload, not uploading to the correct path after configure.
f.mp4
How to Reproduce?

  1. Enable auto upload for new detected media folder
  2. InstantUpload folder will be used for auto upload
  3. Configure the auto upload path (e.g. MyFavFolder) for selected folder
  4. Still uploading to the InstantUpload folder

I think this is also an issue on master (could you pls test). When you activate auto upload and then afterward change the directory for upload, it already uploaded the files to the wrong directory. Only new files will be uploaded to the newly specified folder. To mitigate this, you can activate and change the path of the folder using the 3 dot menu in one go.

Issue

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
…but-videos-also-auto-synced' into 13035-only-pictures-are-enabled-but-videos-also-auto-synced

# Conflicts:
#	app/src/main/java/com/owncloud/android/datamodel/SyncedFolder.java
Copy link

Codacy

Lint

TypemasterPR
Warnings6363
Errors33

SpotBugs

CategoryBaseNew
Bad practice6363
Correctness6363
Dodgy code308308
Experimental11
Internationalization77
Multithreaded correctness66
Performance5252
Security1818
Total518518

Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/13255.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@alperozturk96 alperozturk96 merged commit dad6486 into master Jul 12, 2024
21 checks passed
@JonasMayerDev JonasMayerDev deleted the 13035-only-pictures-are-enabled-but-videos-also-auto-synced branch July 30, 2024 10:55
Copy link

github-actions bot commented Aug 6, 2024

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants