nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.5k stars 4.08k forks source link

File attributes get lost when uploaded to a external SMB/CIFS share #48885

Open dahumph opened 1 month ago

dahumph commented 1 month ago

⚠️ This issue respects the following points: ⚠️

Bug description

When using SMB share as external storage and one does upload a file via any endpoint (browser/desktop app/ios app) to that share, file attributes change.

Steps to reproduce

  1. Configure a SMB/CIFS share as external storage
  2. upload a file, e.g. a photo to that share
  3. check the file attribute of the uploaded photo on the SMB share, learn that the date/time of last modified is set to the time when uploaded to the share, not date/time when you took the photo, as the file had before.
  4. feel annoyed of that behavior, because your photo library is a mess now...

My setup: nextcloud latest stable, nginx, mysql, tested using desktop app, ios app and firefox as client.

Expected behavior

Leave file attributes untouched, like any other smb client using that same share does.

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

None

Web server

Nginx

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

occ config:list system:

{ "system": { "passwordsalt": "REMOVED SENSITIVE VALUE", "secret": "REMOVED SENSITIVE VALUE", "trusteddomains": [ "XXXXX" ], "datadirectory": "REMOVED SENSITIVE VALUE", "dbtype": "mysql", "version": "30.0.0.14", "overwrite.cli.url": "https:\/\/nc.humph.ddnss.de", "dbname": "REMOVED SENSITIVE VALUE", "dbhost": "REMOVED SENSITIVE VALUE", "dbport": "", "dbtableprefix": "oc", "mysql.utf8mb4": true, "dbuser": "REMOVED SENSITIVE VALUE", "dbpassword": "REMOVED SENSITIVE VALUE", "installed": true, "instanceid": "REMOVED SENSITIVE VALUE", "overwritehost": "XXXXXX", "activity_expire_days": 14, "allow_local_remote_servers": true, "auth.bruteforce.protection.enabled": true, "forbidden_filenames": [ ".htaccess", "Thumbs.db", "thumbs.db" ], "cron_log": true, "default_phone_region": "XX", "enable_previews": true, "enabledPreviewProviders": [ "OC\Preview\PNG", "OC\Preview\JPEG", "OC\Preview\GIF", "OC\Preview\BMP", "OC\Preview\XBitmap", "OC\Preview\Movie", "OC\Preview\PDF", "OC\Preview\MP3", "OC\Preview\TXT", "OC\Preview\MarkDown", "OC\Preview\HEIC", "OC\Preview\Movie", "OC\Preview\MKV", "OC\Preview\MP4", "OC\Preview\AVI" ], "filesystem_check_changes": 0, "filelocking.enabled": "true", "htaccess.RewriteBase": "\/", "integrity.check.disabled": false, "knowledgebaseenabled": false, "log_rotate_size": "104857600", "logfile": "\/var\/log\/nextcloud\/nextcloud.log", "loglevel": 2, "logtimezone": "XXXXX", "memcache.local": "\OC\Memcache\APCu", "memcache.locking": "\OC\Memcache\Redis", "overwriteprotocol": "https", "preview_max_x": 1024, "preview_max_y": 768, "preview_max_scale_factor": 1, "profile.enabled": false, "redis": { "host": "REMOVED SENSITIVE VALUE", "port": 0, "password": "REMOVED SENSITIVE VALUE", "timeout": 0.5, "dbindex": 1 }, "quota_include_external_storage": false, "share_folder": "\/Shared", "skeletondirectory": "", "trashbin_retention_obligation": "auto, 7", "maintenance_window_start": 1, "maintenance": false, "mail_from_address": "REMOVED SENSITIVE VALUE", "mail_smtpmode": "smtp", "mail_sendmailmode": "smtp", "mail_domain": "REMOVED SENSITIVE VALUE", "mail_smtphost": "REMOVED SENSITIVE VALUE", "mail_smtpport": "587", "mail_smtpauth": 1, "mail_smtpname": "REMOVED SENSITIVE VALUE", "mail_smtppassword": "REMOVED SENSITIVE VALUE", "auto_logout": true

List of activated Apps

occ app:list:

Enabled:

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

No response

Additional info

No response

MrRinkana commented 2 weeks ago

I can not reproduce this with local external storage, on nc 29.0.9, the web ui shows the correct "last modified", same as upload to nc on storage. Maybe limited to SMB external storages or nc 30?

If it helps: if your images have exif dates, the app memories will show them correctly, as it parses exif data rather than file metadata. File metadata is in general risky to rely on for ordering, many tools touch the file metadata date (both correctly and incorrectly). Not to take away from the validity of this issue, which is definitively undesired behaviour.

dahumph commented 1 week ago

I can not reproduce this with local external storage, on nc 29.0.9, the web ui shows the correct "last modified", same as upload to nc on storage. Maybe limited to SMB external storages or nc 30?

In the web ui the dates indeed are correctly reproduced, I assume the database holds data about the last modified value independent of the value the file has on the (physical) disk, would probably also be consistent with requirements regarding versioning. However, the date of creation value of the file itself (on the disk!) does change when moved or copied to the smb storage using NC web ui, which is afaik inconsistent to what is expected. NC at this point acts as a SMB client, and literally all SMB clients I used so far do keep that value of an existing file when moving/copying to a share.