@@ -60,14 +60,12 @@ class UploadsStorageManager(
6060 try {
6161 this .capability = CapabilityUtils .getCapability(MainApp .getAppContext())
6262 } catch (e: RuntimeException ) {
63- Log_OC .e(TAG , " Failed to set OCCapability: Dependencies are not yet ready." )
63+ Log_OC .e(TAG , " Failed to set OCCapability: Dependencies are not yet ready. $e " )
6464 }
6565 }
6666
6767 @Synchronized
6868 fun updateUpload (ocUpload : OCUpload ): Int {
69- Log_OC .v(TAG , " Updating " + ocUpload.localPath + " with status=" + ocUpload.uploadStatus)
70-
7169 val existingUpload = getUploadById(ocUpload.uploadId)
7270 if (existingUpload == null ) {
7371 Log_OC .e(TAG , " Upload not found for ID: " + ocUpload.uploadId)
@@ -83,6 +81,8 @@ class UploadsStorageManager(
8381 return 0
8482 }
8583
84+ Log_OC .v(TAG , " Updating " + ocUpload.localPath + " with status=" + ocUpload.uploadStatus)
85+
8686 val cv = ContentValues ().apply {
8787 put(ProviderTableMeta .UPLOADS_LOCAL_PATH , ocUpload.localPath)
8888 put(ProviderTableMeta .UPLOADS_REMOTE_PATH , ocUpload.remotePath)
@@ -96,14 +96,15 @@ class UploadsStorageManager(
9696 put(ProviderTableMeta .UPLOADS_FOLDER_UNLOCK_TOKEN , ocUpload.folderUnlockToken)
9797 }
9898
99- val result: Int = contentResolver.update(
99+ val result = contentResolver.update(
100100 ProviderTableMeta .CONTENT_URI_UPLOADS ,
101101 cv,
102102 ProviderTableMeta ._ID + " =? AND " + ProviderTableMeta .UPLOADS_ACCOUNT_NAME + " =?" ,
103103 arrayOf<String >(ocUpload.uploadId.toString(), ocUpload.accountName)
104104 )
105105
106106 Log_OC .d(TAG , " updateUpload returns with: " + result + " for file: " + ocUpload.localPath)
107+
107108 if (result != SINGLE_RESULT ) {
108109 Log_OC .e(TAG , " Failed to update item " + ocUpload.localPath + " into upload db." )
109110 } else {
@@ -114,7 +115,10 @@ class UploadsStorageManager(
114115 }
115116
116117 private fun updateUploadInternal (
117- c : Cursor , status : UploadStatus ? , result : UploadResult ? , remotePath : String? ,
118+ c : Cursor ,
119+ status : UploadStatus ? ,
120+ result : UploadResult ? ,
121+ remotePath : String? ,
118122 localPath : String?
119123 ): Int {
120124 var r = 0
@@ -148,7 +152,10 @@ class UploadsStorageManager(
148152 }
149153
150154 private fun updateUploadStatus (
151- id : Long , status : UploadStatus ? , result : UploadResult ? , remotePath : String? ,
155+ id : Long ,
156+ status : UploadStatus ? ,
157+ result : UploadResult ? ,
158+ remotePath : String? ,
152159 localPath : String?
153160 ) {
154161 val c = contentResolver.query(
@@ -175,7 +182,7 @@ class UploadsStorageManager(
175182 }
176183
177184 fun notifyObserversNow () {
178- Log_OC .d(TAG , " notifyObserversNow " )
185+ Log_OC .d(TAG , " notifying upload storage manager observers " )
179186 Handler (Looper .getMainLooper()).post {
180187 setChanged()
181188 notifyObservers()
@@ -187,7 +194,7 @@ class UploadsStorageManager(
187194 }
188195
189196 fun removeUpload (id : Long ): Int {
190- val result: Int = contentResolver.delete(
197+ val result = contentResolver.delete(
191198 ProviderTableMeta .CONTENT_URI_UPLOADS ,
192199 ProviderTableMeta ._ID + " =?" ,
193200 arrayOf(id.toString())
@@ -199,8 +206,8 @@ class UploadsStorageManager(
199206 return result
200207 }
201208
202- fun removeUpload (accountName : String? , remotePath : String? ): Int {
203- val result: Int = contentResolver.delete(
209+ private fun removeUpload (accountName : String? , remotePath : String? ): Int {
210+ val result = contentResolver.delete(
204211 ProviderTableMeta .CONTENT_URI_UPLOADS ,
205212 ProviderTableMeta .UPLOADS_ACCOUNT_NAME + " =? AND " + ProviderTableMeta .UPLOADS_REMOTE_PATH + " =?" ,
206213 arrayOf(accountName, remotePath)
@@ -213,7 +220,7 @@ class UploadsStorageManager(
213220 }
214221
215222 fun removeUploads (accountName : String? ): Int {
216- val result: Int = contentResolver.delete(
223+ val result = contentResolver.delete(
217224 ProviderTableMeta .CONTENT_URI_UPLOADS ,
218225 ProviderTableMeta .UPLOADS_ACCOUNT_NAME + " =?" ,
219226 arrayOf(accountName)
@@ -493,6 +500,7 @@ class UploadsStorageManager(
493500 upload.remotePath
494501 )
495502 )
503+
496504 updateUploadStatus(upload.ocUploadId, status, result, upload.remotePath, localPath)
497505 }
498506
0 commit comments