Browse Source

use localID everywhere

Co-authored-by: Álvaro Brey <alvaro.brey@nextcloud.com>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 3 years ago
parent
commit
b78e991d54
25 changed files with 1270 additions and 51 deletions
  1. 1130 0
      app/schemas/com.nextcloud.client.database.NextcloudDatabase/67.json
  2. 27 1
      app/src/androidTest/java/com/owncloud/android/datamodel/FileDataStorageManagerContentProviderClientIT.java
  3. 1 0
      app/src/androidTest/java/com/owncloud/android/datamodel/FileDataStorageManagerIT.java
  4. 2 1
      app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt
  5. 2 0
      app/src/main/java/com/nextcloud/client/database/entity/FileEntity.kt
  6. 1 1
      app/src/main/java/com/nextcloud/client/media/LoadUrlTask.kt
  7. 1 1
      app/src/main/java/com/nextcloud/client/media/Player.kt
  8. 1 0
      app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java
  9. 17 12
      app/src/main/java/com/owncloud/android/datamodel/OCFile.java
  10. 4 4
      app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
  11. 3 1
      app/src/main/java/com/owncloud/android/db/ProviderMeta.java
  12. 3 3
      app/src/main/java/com/owncloud/android/files/StreamMediaFileOperation.java
  13. 2 2
      app/src/main/java/com/owncloud/android/operations/CommentFileOperation.java
  14. 5 5
      app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java
  15. 5 5
      app/src/main/java/com/owncloud/android/operations/RichDocumentsUrlOperation.java
  16. 1 1
      app/src/main/java/com/owncloud/android/services/OperationsService.java
  17. 2 2
      app/src/main/java/com/owncloud/android/ui/events/EncryptionEvent.java
  18. 8 6
      app/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java
  19. 1 1
      app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
  20. 1 1
      app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
  21. 3 3
      app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java
  22. 2 0
      app/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java
  23. 1 0
      app/src/main/java/com/owncloud/android/utils/FileStorageUtils.java
  24. 46 0
      app/src/test/java/com/owncloud/android/datamodel/OCFileTest.kt
  25. 1 1
      build.gradle

+ 1130 - 0
app/schemas/com.nextcloud.client.database.NextcloudDatabase/67.json

@@ -0,0 +1,1130 @@
+{
+    "formatVersion": 1,
+    "database": {
+        "version": 67,
+        "identityHash": "be969fd72e75dd6116b4fa746bcf5b6a",
+        "entities": [
+            {
+                "tableName": "arbitrary_data",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `cloud_id` TEXT, `key` TEXT, `value` TEXT)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "cloudId",
+                        "columnName": "cloud_id",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "key",
+                        "columnName": "key",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "value",
+                        "columnName": "value",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "capabilities",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `account` TEXT, `version_mayor` INTEGER, `version_minor` INTEGER, `version_micro` INTEGER, `version_string` TEXT, `version_edition` TEXT, `extended_support` INTEGER, `core_pollinterval` INTEGER, `sharing_api_enabled` INTEGER, `sharing_public_enabled` INTEGER, `sharing_public_password_enforced` INTEGER, `sharing_public_expire_date_enabled` INTEGER, `sharing_public_expire_date_days` INTEGER, `sharing_public_expire_date_enforced` INTEGER, `sharing_public_send_mail` INTEGER, `sharing_public_upload` INTEGER, `sharing_user_send_mail` INTEGER, `sharing_resharing` INTEGER, `sharing_federation_outgoing` INTEGER, `sharing_federation_incoming` INTEGER, `files_bigfilechunking` INTEGER, `files_undelete` INTEGER, `files_versioning` INTEGER, `external_links` INTEGER, `server_name` TEXT, `server_color` TEXT, `server_text_color` TEXT, `server_element_color` TEXT, `server_slogan` TEXT, `server_logo` TEXT, `background_url` TEXT, `end_to_end_encryption` INTEGER, `end_to_end_encryption_keys_exist` INTEGER, `activity` INTEGER, `background_default` INTEGER, `background_plain` INTEGER, `richdocument` INTEGER, `richdocument_mimetype_list` TEXT, `richdocument_direct_editing` INTEGER, `richdocument_direct_templates` INTEGER, `richdocument_optional_mimetype_list` TEXT, `sharing_public_ask_for_optional_password` INTEGER, `richdocument_product_name` TEXT, `direct_editing_etag` TEXT, `user_status` INTEGER, `user_status_supports_emoji` INTEGER, `etag` TEXT, `files_locking_version` TEXT)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "accountName",
+                        "columnName": "account",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "versionMajor",
+                        "columnName": "version_mayor",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "versionMinor",
+                        "columnName": "version_minor",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "versionMicro",
+                        "columnName": "version_micro",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "versionString",
+                        "columnName": "version_string",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "versionEditor",
+                        "columnName": "version_edition",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "extendedSupport",
+                        "columnName": "extended_support",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "corePollinterval",
+                        "columnName": "core_pollinterval",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingApiEnabled",
+                        "columnName": "sharing_api_enabled",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicEnabled",
+                        "columnName": "sharing_public_enabled",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicPasswordEnforced",
+                        "columnName": "sharing_public_password_enforced",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicExpireDateEnabled",
+                        "columnName": "sharing_public_expire_date_enabled",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicExpireDateDays",
+                        "columnName": "sharing_public_expire_date_days",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicExpireDateEnforced",
+                        "columnName": "sharing_public_expire_date_enforced",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicSendMail",
+                        "columnName": "sharing_public_send_mail",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicUpload",
+                        "columnName": "sharing_public_upload",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingUserSendMail",
+                        "columnName": "sharing_user_send_mail",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingResharing",
+                        "columnName": "sharing_resharing",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingFederationOutgoing",
+                        "columnName": "sharing_federation_outgoing",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingFederationIncoming",
+                        "columnName": "sharing_federation_incoming",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "filesBigfilechunking",
+                        "columnName": "files_bigfilechunking",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "filesUndelete",
+                        "columnName": "files_undelete",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "filesVersioning",
+                        "columnName": "files_versioning",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "externalLinks",
+                        "columnName": "external_links",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverName",
+                        "columnName": "server_name",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverColor",
+                        "columnName": "server_color",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverTextColor",
+                        "columnName": "server_text_color",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverElementColor",
+                        "columnName": "server_element_color",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverSlogan",
+                        "columnName": "server_slogan",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverLogo",
+                        "columnName": "server_logo",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverBackgroundUrl",
+                        "columnName": "background_url",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "endToEndEncryption",
+                        "columnName": "end_to_end_encryption",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "endToEndEncryptionKeysExist",
+                        "columnName": "end_to_end_encryption_keys_exist",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "activity",
+                        "columnName": "activity",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverBackgroundDefault",
+                        "columnName": "background_default",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "serverBackgroundPlain",
+                        "columnName": "background_plain",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "richdocument",
+                        "columnName": "richdocument",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "richdocumentMimetypeList",
+                        "columnName": "richdocument_mimetype_list",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "richdocumentDirectEditing",
+                        "columnName": "richdocument_direct_editing",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "richdocumentTemplates",
+                        "columnName": "richdocument_direct_templates",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "richdocumentOptionalMimetypeList",
+                        "columnName": "richdocument_optional_mimetype_list",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharingPublicAskForOptionalPassword",
+                        "columnName": "sharing_public_ask_for_optional_password",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "richdocumentProductName",
+                        "columnName": "richdocument_product_name",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "directEditingEtag",
+                        "columnName": "direct_editing_etag",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "userStatus",
+                        "columnName": "user_status",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "userStatusSupportsEmoji",
+                        "columnName": "user_status_supports_emoji",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "etag",
+                        "columnName": "etag",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "filesLockingVersion",
+                        "columnName": "files_locking_version",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "external_links",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `icon_url` TEXT, `language` TEXT, `type` INTEGER, `name` TEXT, `url` TEXT, `redirect` INTEGER)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "iconUrl",
+                        "columnName": "icon_url",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "language",
+                        "columnName": "language",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "type",
+                        "columnName": "type",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "name",
+                        "columnName": "name",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "url",
+                        "columnName": "url",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "redirect",
+                        "columnName": "redirect",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "filelist",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `filename` TEXT, `encrypted_filename` TEXT, `path` TEXT, `path_decrypted` TEXT, `parent` INTEGER, `created` INTEGER, `modified` INTEGER, `content_type` TEXT, `content_length` INTEGER, `media_path` TEXT, `file_owner` TEXT, `last_sync_date` INTEGER, `last_sync_date_for_data` INTEGER, `modified_at_last_sync_for_data` INTEGER, `etag` TEXT, `etag_on_server` TEXT, `share_by_link` INTEGER, `permissions` TEXT, `remote_id` TEXT, `local_id` INTEGER, `update_thumbnail` INTEGER, `is_downloading` INTEGER, `favorite` INTEGER, `is_encrypted` INTEGER, `etag_in_conflict` TEXT, `shared_via_users` INTEGER, `mount_type` INTEGER, `has_preview` INTEGER, `unread_comments_count` INTEGER, `owner_id` TEXT, `owner_display_name` TEXT, `note` TEXT, `sharees` TEXT, `rich_workspace` TEXT, `metadata_size` TEXT, `locked` INTEGER, `lock_type` INTEGER, `lock_owner` TEXT, `lock_owner_display_name` TEXT, `lock_owner_editor` TEXT, `lock_timestamp` INTEGER, `lock_timeout` INTEGER, `lock_token` TEXT)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "name",
+                        "columnName": "filename",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "encryptedName",
+                        "columnName": "encrypted_filename",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "path",
+                        "columnName": "path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "pathDecrypted",
+                        "columnName": "path_decrypted",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "parent",
+                        "columnName": "parent",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "creation",
+                        "columnName": "created",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "modified",
+                        "columnName": "modified",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "contentType",
+                        "columnName": "content_type",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "contentLength",
+                        "columnName": "content_length",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "storagePath",
+                        "columnName": "media_path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "accountOwner",
+                        "columnName": "file_owner",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lastSyncDate",
+                        "columnName": "last_sync_date",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lastSyncDateForData",
+                        "columnName": "last_sync_date_for_data",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "modifiedAtLastSyncForData",
+                        "columnName": "modified_at_last_sync_for_data",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "etag",
+                        "columnName": "etag",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "etagOnServer",
+                        "columnName": "etag_on_server",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharedViaLink",
+                        "columnName": "share_by_link",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "permissions",
+                        "columnName": "permissions",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "remoteId",
+                        "columnName": "remote_id",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "localId",
+                        "columnName": "local_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "updateThumbnail",
+                        "columnName": "update_thumbnail",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "isDownloading",
+                        "columnName": "is_downloading",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "favorite",
+                        "columnName": "favorite",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "isEncrypted",
+                        "columnName": "is_encrypted",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "etagInConflict",
+                        "columnName": "etag_in_conflict",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharedWithSharee",
+                        "columnName": "shared_via_users",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "mountType",
+                        "columnName": "mount_type",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "hasPreview",
+                        "columnName": "has_preview",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "unreadCommentsCount",
+                        "columnName": "unread_comments_count",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "ownerId",
+                        "columnName": "owner_id",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "ownerDisplayName",
+                        "columnName": "owner_display_name",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "note",
+                        "columnName": "note",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharees",
+                        "columnName": "sharees",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "richWorkspace",
+                        "columnName": "rich_workspace",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "metadataSize",
+                        "columnName": "metadata_size",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "locked",
+                        "columnName": "locked",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lockType",
+                        "columnName": "lock_type",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lockOwner",
+                        "columnName": "lock_owner",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lockOwnerDisplayName",
+                        "columnName": "lock_owner_display_name",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lockOwnerEditor",
+                        "columnName": "lock_owner_editor",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lockTimestamp",
+                        "columnName": "lock_timestamp",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lockTimeout",
+                        "columnName": "lock_timeout",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lockToken",
+                        "columnName": "lock_token",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "filesystem",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `local_path` TEXT, `is_folder` INTEGER, `found_at` INTEGER, `upload_triggered` INTEGER, `syncedfolder_id` TEXT, `crc32` TEXT, `modified_at` INTEGER)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "localPath",
+                        "columnName": "local_path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "fileIsFolder",
+                        "columnName": "is_folder",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "fileFoundRecently",
+                        "columnName": "found_at",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "fileSentForUpload",
+                        "columnName": "upload_triggered",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "syncedFolderId",
+                        "columnName": "syncedfolder_id",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "crc32",
+                        "columnName": "crc32",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "fileModified",
+                        "columnName": "modified_at",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "ocshares",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `file_source` INTEGER, `item_source` INTEGER, `share_type` INTEGER, `shate_with` TEXT, `path` TEXT, `permissions` INTEGER, `shared_date` INTEGER, `expiration_date` INTEGER, `token` TEXT, `shared_with_display_name` TEXT, `is_directory` INTEGER, `user_id` INTEGER, `id_remote_shared` INTEGER, `owner_share` TEXT, `is_password_protected` INTEGER, `note` TEXT, `hide_download` INTEGER, `share_link` TEXT, `share_label` TEXT)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "fileSource",
+                        "columnName": "file_source",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "itemSource",
+                        "columnName": "item_source",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "shareType",
+                        "columnName": "share_type",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "shareWith",
+                        "columnName": "shate_with",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "path",
+                        "columnName": "path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "permissions",
+                        "columnName": "permissions",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "sharedDate",
+                        "columnName": "shared_date",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "expirationDate",
+                        "columnName": "expiration_date",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "token",
+                        "columnName": "token",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "shareWithDisplayName",
+                        "columnName": "shared_with_display_name",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "isDirectory",
+                        "columnName": "is_directory",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "userId",
+                        "columnName": "user_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "idRemoteShared",
+                        "columnName": "id_remote_shared",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "accountOwner",
+                        "columnName": "owner_share",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "isPasswordProtected",
+                        "columnName": "is_password_protected",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "note",
+                        "columnName": "note",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "hideDownload",
+                        "columnName": "hide_download",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "shareLink",
+                        "columnName": "share_link",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "shareLabel",
+                        "columnName": "share_label",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "synced_folders",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `local_path` TEXT, `remote_path` TEXT, `wifi_only` INTEGER, `charging_only` INTEGER, `existing` INTEGER, `enabled` INTEGER, `enabled_timestamp_ms` INTEGER, `subfolder_by_date` INTEGER, `account` TEXT, `upload_option` INTEGER, `name_collision_policy` INTEGER, `type` INTEGER, `hidden` INTEGER)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "localPath",
+                        "columnName": "local_path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "remotePath",
+                        "columnName": "remote_path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "wifiOnly",
+                        "columnName": "wifi_only",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "chargingOnly",
+                        "columnName": "charging_only",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "existing",
+                        "columnName": "existing",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "enabled",
+                        "columnName": "enabled",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "enabledTimestampMs",
+                        "columnName": "enabled_timestamp_ms",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "subfolderByDate",
+                        "columnName": "subfolder_by_date",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "account",
+                        "columnName": "account",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "uploadAction",
+                        "columnName": "upload_option",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "nameCollisionPolicy",
+                        "columnName": "name_collision_policy",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "type",
+                        "columnName": "type",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "hidden",
+                        "columnName": "hidden",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "list_of_uploads",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `local_path` TEXT, `remote_path` TEXT, `account_name` TEXT, `file_size` INTEGER, `status` INTEGER, `local_behaviour` INTEGER, `upload_time` INTEGER, `name_collision_policy` INTEGER, `is_create_remote_folder` INTEGER, `upload_end_timestamp` INTEGER, `last_result` INTEGER, `is_while_charging_only` INTEGER, `is_wifi_only` INTEGER, `created_by` INTEGER, `folder_unlock_token` TEXT)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "localPath",
+                        "columnName": "local_path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "remotePath",
+                        "columnName": "remote_path",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "accountName",
+                        "columnName": "account_name",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "fileSize",
+                        "columnName": "file_size",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "status",
+                        "columnName": "status",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "localBehaviour",
+                        "columnName": "local_behaviour",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "uploadTime",
+                        "columnName": "upload_time",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "nameCollisionPolicy",
+                        "columnName": "name_collision_policy",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "isCreateRemoteFolder",
+                        "columnName": "is_create_remote_folder",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "uploadEndTimestamp",
+                        "columnName": "upload_end_timestamp",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "lastResult",
+                        "columnName": "last_result",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "isWhileChargingOnly",
+                        "columnName": "is_while_charging_only",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "isWifiOnly",
+                        "columnName": "is_wifi_only",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "createdBy",
+                        "columnName": "created_by",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "folderUnlockToken",
+                        "columnName": "folder_unlock_token",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            },
+            {
+                "tableName": "virtual",
+                "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `type` TEXT, `ocfile_id` INTEGER)",
+                "fields": [
+                    {
+                        "fieldPath": "id",
+                        "columnName": "_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "type",
+                        "columnName": "type",
+                        "affinity": "TEXT",
+                        "notNull": false
+                    },
+                    {
+                        "fieldPath": "ocFileId",
+                        "columnName": "ocfile_id",
+                        "affinity": "INTEGER",
+                        "notNull": false
+                    }
+                ],
+                "primaryKey": {
+                    "columnNames": [
+                        "_id"
+                    ],
+                    "autoGenerate": true
+                },
+                "indices": [],
+                "foreignKeys": []
+            }
+        ],
+        "views": [],
+        "setupQueries": [
+            "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+            "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'be969fd72e75dd6116b4fa746bcf5b6a')"
+        ]
+    }
+}

+ 27 - 1
app/src/androidTest/java/com/owncloud/android/datamodel/FileDataStorageManagerContentProviderClientIT.java

@@ -24,9 +24,14 @@ package com.owncloud.android.datamodel;
 
 
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.db.ProviderMeta;
 
 
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 public class FileDataStorageManagerContentProviderClientIT extends FileDataStorageManagerIT {
 public class FileDataStorageManagerContentProviderClientIT extends FileDataStorageManagerIT {
+    protected FileDataStorageManager sut;
 
 
-    @Override
     public void before() {
     public void before() {
         sut = new FileDataStorageManager(user,
         sut = new FileDataStorageManager(user,
                                          targetContext
                                          targetContext
@@ -36,4 +41,25 @@ public class FileDataStorageManagerContentProviderClientIT extends FileDataStora
 
 
         super.before();
         super.before();
     }
     }
+
+    @Test
+    public void saveFile() {
+        before();
+
+        String path = "/1.txt";
+        OCFile file = new OCFile(path);
+        file.setRemoteId("00000008ocjycgrudn78");
+
+        // TODO check via reflection that every parameter is set
+
+        file.setFileLength(1024000);
+        file.setModificationTimestamp(1582019340);
+        sut.saveNewFile(file);
+
+
+        OCFile read = sut.getFileByPath(path);
+        assertNotNull(read);
+
+        assertEquals(file.getRemotePath(), read.getRemotePath());
+    }
 }
 }

+ 1 - 0
app/src/androidTest/java/com/owncloud/android/datamodel/FileDataStorageManagerIT.java

@@ -369,4 +369,5 @@ abstract public class FileDataStorageManagerIT extends AbstractOnServerIT {
 
 
         assertEquals(capability.getUserStatus(), newCapability.getUserStatus());
         assertEquals(capability.getUserStatus(), newCapability.getUserStatus());
     }
     }
+
 }
 }

+ 2 - 1
app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt

@@ -58,7 +58,8 @@ import com.owncloud.android.db.ProviderMeta
     ],
     ],
     version = ProviderMeta.DB_VERSION,
     version = ProviderMeta.DB_VERSION,
     autoMigrations = [
     autoMigrations = [
-        AutoMigration(from = 65, to = 66)
+        AutoMigration(from = 65, to = 66),
+        AutoMigration(from = 66, to = 67)
     ],
     ],
     exportSchema = true
     exportSchema = true
 )
 )

+ 2 - 0
app/src/main/java/com/nextcloud/client/database/entity/FileEntity.kt

@@ -70,6 +70,8 @@ data class FileEntity(
     val permissions: String?,
     val permissions: String?,
     @ColumnInfo(name = ProviderTableMeta.FILE_REMOTE_ID)
     @ColumnInfo(name = ProviderTableMeta.FILE_REMOTE_ID)
     val remoteId: String?,
     val remoteId: String?,
+    @ColumnInfo(name = ProviderTableMeta.FILE_LOCAL_ID)
+    val localId: Long?,
     @ColumnInfo(name = ProviderTableMeta.FILE_UPDATE_THUMBNAIL)
     @ColumnInfo(name = ProviderTableMeta.FILE_UPDATE_THUMBNAIL)
     val updateThumbnail: Int?,
     val updateThumbnail: Int?,
     @ColumnInfo(name = ProviderTableMeta.FILE_IS_DOWNLOADING)
     @ColumnInfo(name = ProviderTableMeta.FILE_IS_DOWNLOADING)

+ 1 - 1
app/src/main/java/com/nextcloud/client/media/LoadUrlTask.kt

@@ -28,7 +28,7 @@ import com.owncloud.android.lib.common.OwnCloudClient
 
 
 internal class LoadUrlTask(
 internal class LoadUrlTask(
     private val client: OwnCloudClient,
     private val client: OwnCloudClient,
-    private val fileId: String,
+    private val fileId: Long,
     private val onResult: (String?) -> Unit
     private val onResult: (String?) -> Unit
 ) : AsyncTask<Void, Void, String>() {
 ) : AsyncTask<Void, Void, String>() {
 
 

+ 1 - 1
app/src/main/java/com/nextcloud/client/media/Player.kt

@@ -96,7 +96,7 @@ internal class Player(
             checkNotNull(user)
             checkNotNull(user)
             playedFile?.let {
             playedFile?.let {
                 val client = clientFactory.create(user)
                 val client = clientFactory.create(user)
-                val task = LoadUrlTask(client, it.remoteId, this@Player::onDownloaded)
+                val task = LoadUrlTask(client, it.localId, this@Player::onDownloaded)
                 task.execute()
                 task.execute()
                 loadUrlTask = task
                 loadUrlTask = task
             }
             }

+ 1 - 0
app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -458,6 +458,7 @@ public class FileDataStorageManager {
         cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, fileOrFolder.isSharedWithSharee() ? 1 : 0);
         cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, fileOrFolder.isSharedWithSharee() ? 1 : 0);
         cv.put(ProviderTableMeta.FILE_PERMISSIONS, fileOrFolder.getPermissions());
         cv.put(ProviderTableMeta.FILE_PERMISSIONS, fileOrFolder.getPermissions());
         cv.put(ProviderTableMeta.FILE_REMOTE_ID, fileOrFolder.getRemoteId());
         cv.put(ProviderTableMeta.FILE_REMOTE_ID, fileOrFolder.getRemoteId());
+        cv.put(ProviderTableMeta.FILE_LOCAL_ID, fileOrFolder.getLocalId());
         cv.put(ProviderTableMeta.FILE_FAVORITE, fileOrFolder.isFavorite());
         cv.put(ProviderTableMeta.FILE_FAVORITE, fileOrFolder.isFavorite());
         cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, fileOrFolder.getUnreadCommentsCount());
         cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, fileOrFolder.getUnreadCommentsCount());
         cv.put(ProviderTableMeta.FILE_OWNER_ID, fileOrFolder.getOwnerId());
         cv.put(ProviderTableMeta.FILE_OWNER_ID, fileOrFolder.getOwnerId());

+ 17 - 12
app/src/main/java/com/owncloud/android/datamodel/OCFile.java

@@ -45,6 +45,7 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.Nullable;
 import androidx.annotation.VisibleForTesting;
 import androidx.annotation.VisibleForTesting;
 import androidx.core.content.FileProvider;
 import androidx.core.content.FileProvider;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import third_parties.daveKoeller.AlphanumComparator;
 import third_parties.daveKoeller.AlphanumComparator;
 
 
 public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
 public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
@@ -83,6 +84,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
     private String etagOnServer;
     private String etagOnServer;
     private boolean sharedViaLink;
     private boolean sharedViaLink;
     private String permissions;
     private String permissions;
+    private long localId; // unique fileId for the file within the instance
     private String remoteId; // The fileid namespaced by the instance fileId, globally unique
     private String remoteId; // The fileid namespaced by the instance fileId, globally unique
     private boolean updateThumbnailNeeded;
     private boolean updateThumbnailNeeded;
     private boolean downloading;
     private boolean downloading;
@@ -166,6 +168,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
         etagOnServer = source.readString();
         etagOnServer = source.readString();
         sharedViaLink = source.readInt() == 1;
         sharedViaLink = source.readInt() == 1;
         permissions = source.readString();
         permissions = source.readString();
+        localId = source.readLong();
         remoteId = source.readString();
         remoteId = source.readString();
         updateThumbnailNeeded = source.readInt() == 1;
         updateThumbnailNeeded = source.readInt() == 1;
         downloading = source.readInt() == 1;
         downloading = source.readInt() == 1;
@@ -208,6 +211,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
         dest.writeString(etagOnServer);
         dest.writeString(etagOnServer);
         dest.writeInt(sharedViaLink ? 1 : 0);
         dest.writeInt(sharedViaLink ? 1 : 0);
         dest.writeString(permissions);
         dest.writeString(permissions);
+        dest.writeLong(localId);
         dest.writeString(remoteId);
         dest.writeString(remoteId);
         dest.writeInt(updateThumbnailNeeded ? 1 : 0);
         dest.writeInt(updateThumbnailNeeded ? 1 : 0);
         dest.writeInt(downloading ? 1 : 0);
         dest.writeInt(downloading ? 1 : 0);
@@ -284,8 +288,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
     }
     }
 
 
     /**
     /**
-     * Can be used to check, whether or not this file exists in the database
-     * already
+     * Can be used to check, whether or not this file exists in the database already
      *
      *
      * @return true, if the file exists in the database
      * @return true, if the file exists in the database
      */
      */
@@ -486,6 +489,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
         etagOnServer = null;
         etagOnServer = null;
         sharedViaLink = false;
         sharedViaLink = false;
         permissions = null;
         permissions = null;
+        localId = -1;
         remoteId = null;
         remoteId = null;
         updateThumbnailNeeded = false;
         updateThumbnailNeeded = false;
         downloading = false;
         downloading = false;
@@ -594,17 +598,14 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
         return !TextUtils.isEmpty(getFileName()) && getFileName().charAt(0) == '.';
         return !TextUtils.isEmpty(getFileName()) && getFileName().charAt(0) == '.';
     }
     }
 
 
-    /**
-     * The unique fileId for the file within the instance
-     *
-     * @return file fileId, unique within the instance
-     */
-    @Nullable
-    public String getLocalId() {
-        if (getRemoteId() != null) {
-            return getRemoteId().substring(0, 8).replaceAll("^0*", "");
+    @SuppressFBWarnings("STT")
+    public long getLocalId() {
+        if (localId > 0) {
+            return localId;
+        } else if (remoteId != null) {
+            return Long.parseLong(remoteId.substring(0, 8).replaceAll("^0*", ""));
         } else {
         } else {
-            return null;
+            return -1;
         }
         }
     }
     }
 
 
@@ -772,6 +773,10 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
         this.fileId = fileId;
         this.fileId = fileId;
     }
     }
 
 
+    public void setLocalId(long localId) {
+        this.localId = localId;
+    }
+
     public void setParentId(long parentId) {
     public void setParentId(long parentId) {
         this.parentId = parentId;
         this.parentId = parentId;
     }
     }

+ 4 - 4
app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

@@ -689,7 +689,7 @@ public final class ThumbnailsCacheManager {
                         Bitmap bitmap;
                         Bitmap bitmap;
                         if (MimeTypeUtil.isVideo(ocFile)) {
                         if (MimeTypeUtil.isVideo(ocFile)) {
                             bitmap = ThumbnailUtils.createVideoThumbnail(ocFile.getStoragePath(),
                             bitmap = ThumbnailUtils.createVideoThumbnail(ocFile.getStoragePath(),
-                                    MediaStore.Images.Thumbnails.MINI_KIND);
+                                                                         MediaStore.Images.Thumbnails.MINI_KIND);
                         } else {
                         } else {
                             bitmap = BitmapUtils.decodeSampledBitmapFromFile(ocFile.getStoragePath(), pxW, pxH);
                             bitmap = BitmapUtils.decodeSampledBitmapFromFile(ocFile.getStoragePath(), pxW, pxH);
                         }
                         }
@@ -733,16 +733,16 @@ public final class ThumbnailsCacheManager {
                                         pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");
                                         pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");
                                 } else {
                                 } else {
                                     uri = mClient.getBaseUri() + "/index.php/apps/files_trashbin/preview?fileId=" +
                                     uri = mClient.getBaseUri() + "/index.php/apps/files_trashbin/preview?fileId=" +
-                                            file.getLocalId() + "&x=" + pxW + "&y=" + pxH;
+                                        file.getLocalId() + "&x=" + pxW + "&y=" + pxH;
                                 }
                                 }
 
 
                                 Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
                                 Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
                                 getMethod = new GetMethod(uri);
                                 getMethod = new GetMethod(uri);
                                 getMethod.setRequestHeader("Cookie",
                                 getMethod.setRequestHeader("Cookie",
-                                        "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
+                                                           "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
 
 
                                 getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER,
                                 getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER,
-                                        RemoteOperation.OCS_API_HEADER_VALUE);
+                                                           RemoteOperation.OCS_API_HEADER_VALUE);
 
 
                                 int status = mClient.executeMethod(getMethod, READ_TIMEOUT, CONNECTION_TIMEOUT);
                                 int status = mClient.executeMethod(getMethod, READ_TIMEOUT, CONNECTION_TIMEOUT);
                                 if (status == HttpStatus.SC_OK) {
                                 if (status == HttpStatus.SC_OK) {

+ 3 - 1
app/src/main/java/com/owncloud/android/db/ProviderMeta.java

@@ -35,7 +35,7 @@ import java.util.List;
  */
  */
 public class ProviderMeta {
 public class ProviderMeta {
     public static final String DB_NAME = "filelist";
     public static final String DB_NAME = "filelist";
-    public static final int DB_VERSION = 66;
+    public static final int DB_VERSION = 67;
 
 
     private ProviderMeta() {
     private ProviderMeta() {
         // No instance
         // No instance
@@ -101,6 +101,7 @@ public class ProviderMeta {
         public static final String FILE_SHARED_VIA_LINK = "share_by_link";
         public static final String FILE_SHARED_VIA_LINK = "share_by_link";
         public static final String FILE_SHARED_WITH_SHAREE = "shared_via_users";
         public static final String FILE_SHARED_WITH_SHAREE = "shared_via_users";
         public static final String FILE_PERMISSIONS = "permissions";
         public static final String FILE_PERMISSIONS = "permissions";
+        public static final String FILE_LOCAL_ID = "local_id";
         public static final String FILE_REMOTE_ID = "remote_id";
         public static final String FILE_REMOTE_ID = "remote_id";
         public static final String FILE_UPDATE_THUMBNAIL = "update_thumbnail";
         public static final String FILE_UPDATE_THUMBNAIL = "update_thumbnail";
         public static final String FILE_IS_DOWNLOADING = "is_downloading";
         public static final String FILE_IS_DOWNLOADING = "is_downloading";
@@ -148,6 +149,7 @@ public class ProviderMeta {
             FILE_SHARED_WITH_SHAREE,
             FILE_SHARED_WITH_SHAREE,
             FILE_PERMISSIONS,
             FILE_PERMISSIONS,
             FILE_REMOTE_ID,
             FILE_REMOTE_ID,
+            FILE_LOCAL_ID,
             FILE_UPDATE_THUMBNAIL,
             FILE_UPDATE_THUMBNAIL,
             FILE_IS_DOWNLOADING,
             FILE_IS_DOWNLOADING,
             FILE_ETAG_IN_CONFLICT,
             FILE_ETAG_IN_CONFLICT,

+ 3 - 3
app/src/main/java/com/owncloud/android/files/StreamMediaFileOperation.java

@@ -37,7 +37,7 @@ public class StreamMediaFileOperation extends RemoteOperation {
     private static final int SYNC_CONNECTION_TIMEOUT = 5000;
     private static final int SYNC_CONNECTION_TIMEOUT = 5000;
     private static final String STREAM_MEDIA_URL = "/ocs/v2.php/apps/dav/api/v1/direct";
     private static final String STREAM_MEDIA_URL = "/ocs/v2.php/apps/dav/api/v1/direct";
 
 
-    private String fileID;
+    private final long fileID;
 
 
     // JSON node names
     // JSON node names
     private static final String NODE_OCS = "ocs";
     private static final String NODE_OCS = "ocs";
@@ -45,7 +45,7 @@ public class StreamMediaFileOperation extends RemoteOperation {
     private static final String NODE_URL = "url";
     private static final String NODE_URL = "url";
     private static final String JSON_FORMAT = "?format=json";
     private static final String JSON_FORMAT = "?format=json";
 
 
-    public StreamMediaFileOperation(String fileID) {
+    public StreamMediaFileOperation(long fileID) {
         this.fileID = fileID;
         this.fileID = fileID;
     }
     }
 
 
@@ -55,7 +55,7 @@ public class StreamMediaFileOperation extends RemoteOperation {
 
 
         try {
         try {
             postMethod = new Utf8PostMethod(client.getBaseUri() + STREAM_MEDIA_URL + JSON_FORMAT);
             postMethod = new Utf8PostMethod(client.getBaseUri() + STREAM_MEDIA_URL + JSON_FORMAT);
-            postMethod.setParameter("fileId", fileID);
+            postMethod.setParameter("fileId", String.valueOf(fileID));
 
 
             // remote request
             // remote request
             postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
             postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);

+ 2 - 2
app/src/main/java/com/owncloud/android/operations/CommentFileOperation.java

@@ -33,14 +33,14 @@ import com.owncloud.android.lib.resources.comments.CommentFileRemoteOperation;
 public class CommentFileOperation extends RemoteOperation {
 public class CommentFileOperation extends RemoteOperation {
 
 
     private final String message;
     private final String message;
-    private final String fileId;
+    private final long fileId;
 
 
     /**
     /**
      * Constructor
      * Constructor
      *
      *
      * @param message Comment to store
      * @param message Comment to store
      */
      */
-    public CommentFileOperation(String message, String fileId) {
+    public CommentFileOperation(String message, long fileId) {
         this.message = message;
         this.message = message;
         this.fileId = fileId;
         this.fileId = fileId;
     }
     }

+ 5 - 5
app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java

@@ -62,12 +62,12 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
     private static final int REMOVE_READ_TIMEOUT = 30000;
     private static final int REMOVE_READ_TIMEOUT = 30000;
     private static final int REMOVE_CONNECTION_TIMEOUT = 5000;
     private static final int REMOVE_CONNECTION_TIMEOUT = 5000;
 
 
-    private String remotePath;
-    private String parentId;
+    private final String remotePath;
+    private final long parentId;
     private User user;
     private User user;
 
 
-    private ArbitraryDataProvider arbitraryDataProvider;
-    private String fileName;
+    private final ArbitraryDataProvider arbitraryDataProvider;
+    private final String fileName;
 
 
     /**
     /**
      * Constructor
      * Constructor
@@ -76,7 +76,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
      * @param parentId   local id of parent folder
      * @param parentId   local id of parent folder
      */
      */
     RemoveRemoteEncryptedFileOperation(String remotePath,
     RemoveRemoteEncryptedFileOperation(String remotePath,
-                                       String parentId,
+                                       long parentId,
                                        User user,
                                        User user,
                                        Context context,
                                        Context context,
                                        String fileName) {
                                        String fileName) {

+ 5 - 5
app/src/main/java/com/owncloud/android/operations/RichDocumentsUrlOperation.java

@@ -51,10 +51,10 @@ public class RichDocumentsUrlOperation extends RemoteOperation {
     private static final String NODE_URL = "url";
     private static final String NODE_URL = "url";
     private static final String JSON_FORMAT = "?format=json";
     private static final String JSON_FORMAT = "?format=json";
 
 
-    private String fileID;
+    private final long fileId;
 
 
-    public RichDocumentsUrlOperation(String fileID) {
-        this.fileID = fileID;
+    public RichDocumentsUrlOperation(long fileID) {
+        this.fileId = fileID;
     }
     }
 
 
     @NextcloudServer(max = 18)
     @NextcloudServer(max = 18)
@@ -64,7 +64,7 @@ public class RichDocumentsUrlOperation extends RemoteOperation {
 
 
         try {
         try {
             postMethod = new Utf8PostMethod(client.getBaseUri() + DOCUMENT_URL + JSON_FORMAT);
             postMethod = new Utf8PostMethod(client.getBaseUri() + DOCUMENT_URL + JSON_FORMAT);
-            postMethod.setParameter(FILE_ID, fileID);
+            postMethod.setParameter(FILE_ID, String.valueOf(fileId));
 
 
             // remote request
             // remote request
             postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
             postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
@@ -86,7 +86,7 @@ public class RichDocumentsUrlOperation extends RemoteOperation {
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             result = new RemoteOperationResult(e);
             result = new RemoteOperationResult(e);
-            Log_OC.e(TAG, "Get rich document url for file with id " + fileID + " failed: " + result.getLogMessage(),
+            Log_OC.e(TAG, "Get rich document url for file with id " + fileId + " failed: " + result.getLogMessage(),
                      result.getException());
                      result.getException());
         } finally {
         } finally {
             if (postMethod != null) {
             if (postMethod != null) {

+ 1 - 1
app/src/main/java/com/owncloud/android/services/OperationsService.java

@@ -721,7 +721,7 @@ public class OperationsService extends Service {
 
 
                     case ACTION_RESTORE_VERSION:
                     case ACTION_RESTORE_VERSION:
                         FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
                         FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
-                        operation = new RestoreFileVersionRemoteOperation(fileVersion.getRemoteId(),
+                        operation = new RestoreFileVersionRemoteOperation(fileVersion.getLocalId(),
                                                                           fileVersion.getFileName());
                                                                           fileVersion.getFileName());
                         break;
                         break;
 
 

+ 2 - 2
app/src/main/java/com/owncloud/android/ui/events/EncryptionEvent.java

@@ -23,12 +23,12 @@ package com.owncloud.android.ui.events;
  * Event for set folder as encrypted/decrypted
  * Event for set folder as encrypted/decrypted
  */
  */
 public class EncryptionEvent {
 public class EncryptionEvent {
-    public final String localId;
+    public final long localId;
     public final String remotePath;
     public final String remotePath;
     public final String remoteId;
     public final String remoteId;
     public final boolean shouldBeEncrypted;
     public final boolean shouldBeEncrypted;
 
 
-    public EncryptionEvent(String localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
+    public EncryptionEvent(long localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
         this.localId = localId;
         this.localId = localId;
         this.remoteId = remoteId;
         this.remoteId = remoteId;
         this.remotePath = remotePath;
         this.remotePath = remotePath;

+ 8 - 6
app/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java

@@ -457,12 +457,14 @@ public class FileDetailActivitiesFragment extends Fragment implements
 
 
     private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {
     private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {
 
 
-        private String message;
-        private String fileId;
-        private VersionListInterface.CommentCallback callback;
-        private OwnCloudClient client;
-
-        private SubmitCommentTask(String message, String fileId, VersionListInterface.CommentCallback callback,
+        private final String message;
+        private final long fileId;
+        private final VersionListInterface.CommentCallback callback;
+        private final OwnCloudClient client;
+
+        private SubmitCommentTask(String message,
+                                  long fileId,
+                                  VersionListInterface.CommentCallback callback,
                                   OwnCloudClient client) {
                                   OwnCloudClient client) {
             this.message = message;
             this.message = message;
             this.fileId = fileId;
             this.fileId = fileId;

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -1696,7 +1696,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
         }
         }
     }
     }
 
 
-    private void encryptFolder(String localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
+    private void encryptFolder(long localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
         try {
         try {
             User user = accountManager.getUser();
             User user = accountManager.getUser();
             OwnCloudClient client = clientFactory.create(user);
             OwnCloudClient client = clientFactory.create(user);

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java

@@ -456,7 +456,7 @@ public class FileOperationsHelper {
         fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
         fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
         final User user = currentAccount.getUser();
         final User user = currentAccount.getUser();
         new Thread(() -> {
         new Thread(() -> {
-            StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getRemoteId());
+            StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getLocalId());
             RemoteOperationResult result = sfo.execute(user, fileActivity);
             RemoteOperationResult result = sfo.execute(user, fileActivity);
 
 
             fileActivity.dismissLoadingDialog();
             fileActivity.dismissLoadingDialog();

+ 3 - 3
app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -471,7 +471,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
             playVideoUri(getFile().getStorageUri());
             playVideoUri(getFile().getStorageUri());
         } else {
         } else {
             try {
             try {
-                new LoadStreamUrl(this, user, clientFactory).execute(getFile().getRemoteId());
+                new LoadStreamUrl(this, user, clientFactory).execute(getFile().getLocalId());
             } catch (Exception e) {
             } catch (Exception e) {
                 Log_OC.e(TAG, "Loading stream url not possible: " + e);
                 Log_OC.e(TAG, "Loading stream url not possible: " + e);
             }
             }
@@ -498,7 +498,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         Log_OC.e(TAG, "Fullscreen: " + isFullScreen);
         Log_OC.e(TAG, "Fullscreen: " + isFullScreen);
     }
     }
 
 
-    private static class LoadStreamUrl extends AsyncTask<String, Void, Uri> {
+    private static class LoadStreamUrl extends AsyncTask<Long, Void, Uri> {
 
 
         private final ClientFactory clientFactory;
         private final ClientFactory clientFactory;
         private final User user;
         private final User user;
@@ -511,7 +511,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
         }
         }
 
 
         @Override
         @Override
-        protected Uri doInBackground(String... fileId) {
+        protected Uri doInBackground(Long... fileId) {
             OwnCloudClient client;
             OwnCloudClient client;
             try {
             try {
                 client = clientFactory.create(user);
                 client = clientFactory.create(user);

+ 2 - 0
app/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java

@@ -64,6 +64,7 @@ import androidx.annotation.NonNull;
 import androidx.appcompat.widget.SearchView;
 import androidx.appcompat.widget.SearchView;
 import androidx.core.view.MenuItemCompat;
 import androidx.core.view.MenuItemCompat;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentManager;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 
 public class PreviewTextFileFragment extends PreviewTextFragment {
 public class PreviewTextFileFragment extends PreviewTextFragment {
     private static final String EXTRA_FILE = "FILE";
     private static final String EXTRA_FILE = "FILE";
@@ -228,6 +229,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
         }
         }
 
 
         @Override
         @Override
+        @SuppressFBWarnings("STT")
         protected void onPostExecute(final StringWriter stringWriter) {
         protected void onPostExecute(final StringWriter stringWriter) {
             final TextView textView = textViewReference.get();
             final TextView textView = textViewReference.get();
 
 

+ 1 - 0
app/src/main/java/com/owncloud/android/utils/FileStorageUtils.java

@@ -222,6 +222,7 @@ public final class FileStorageUtils {
         file.setEtag(remote.getEtag());
         file.setEtag(remote.getEtag());
         file.setPermissions(remote.getPermissions());
         file.setPermissions(remote.getPermissions());
         file.setRemoteId(remote.getRemoteId());
         file.setRemoteId(remote.getRemoteId());
+        file.setLocalId(remote.getLocalId());
         file.setFavorite(remote.isFavorite());
         file.setFavorite(remote.isFavorite());
         if (file.isFolder()) {
         if (file.isFolder()) {
             file.setEncrypted(remote.isEncrypted());
             file.setEncrypted(remote.isEncrypted());

+ 46 - 0
app/src/test/java/com/owncloud/android/datamodel/OCFileTest.kt

@@ -0,0 +1,46 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2022 Tobias Kaminsky
+ * Copyright (C) 2022 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.owncloud.android.datamodel
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotEquals
+import org.junit.Test
+
+class OCFileTest {
+    @Test
+    fun testLongIds() {
+        val sut = OCFile("/")
+
+        sut.remoteId = "12345678ocjycgrudn78"
+        assertEquals(12345678, sut.localId)
+
+        sut.remoteId = "00000008ocjycgrudn78"
+        assertEquals(8, sut.localId)
+
+        // this will fail as fileId is too large
+        sut.remoteId = "1234567891011ocjycgrudn78"
+        assertNotEquals(1234567891011L, sut.localId)
+
+        sut.localId = 1234567891011L
+        assertEquals(1234567891011L, sut.localId)
+    }
+}

+ 1 - 1
build.gradle

@@ -6,7 +6,7 @@ buildscript {
         daggerVersion = "2.44.2"
         daggerVersion = "2.44.2"
         markwonVersion = "4.6.2"
         markwonVersion = "4.6.2"
         prismVersion = "2.0.0"
         prismVersion = "2.0.0"
-        androidLibraryVersion = "master-SNAPSHOT"
+        androidLibraryVersion = "localId-SNAPSHOT"
         mockitoVersion = "4.11.0"
         mockitoVersion = "4.11.0"
         mockitoKotlinVersion = "4.1.0"
         mockitoKotlinVersion = "4.1.0"
         mockkVersion = "1.13.3"
         mockkVersion = "1.13.3"