Эх сурвалжийг харах

Avoid storing upload if it ias already in current queue

Juan Carlos González Cabrero 9 жил өмнө
parent
commit
1c701fbc00

+ 0 - 20
src/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -326,26 +326,6 @@ public class UploadsStorageManager extends Observable {
         return result;
     }
 
-    /**
-     * Remove a specific upload given his unique ID.
-     *
-     * @param uploadId       unique ID of the upload.
-     * @return true when the upload entry was removed
-     */
-    public int removeUpload(long uploadId) {
-        int result = getDB().delete(
-            ProviderTableMeta.CONTENT_URI_UPLOADS,
-            ProviderTableMeta._ID + "=?",
-            new String[]{String.valueOf(uploadId)}
-        );
-        Log_OC.d(TAG, "delete returns " + result + " for upload with ID " + uploadId);
-        if (result > 0) {
-            notifyObserversNow();
-        }
-        return result;
-    }
-
-
     public OCUpload[] getAllStoredUploads() {
         return getUploads(null, null);
     }

+ 4 - 9
src/com/owncloud/android/files/services/FileUploader.java

@@ -511,11 +511,6 @@ public class FileUploader extends Service
                     ocUpload.setWhileChargingOnly(isWhileChargingOnly);*/
                     ocUpload.setUploadStatus(UploadStatus.UPLOAD_IN_PROGRESS);
 
-                    // storagePath inside upload is the temporary path. file
-                    // contains the correct path used as db reference.
-                    long id = mUploadsStorageManager.storeUpload(ocUpload);
-                    newUpload.setOCUploadId(id);
-
                     Pair<String, String> putResult = mPendingUploads.putIfAbsent(
                             account.name,
                             files[i].getRemotePath(),
@@ -524,10 +519,10 @@ public class FileUploader extends Service
                     if (putResult != null) {
                         uploadKey = putResult.first;
                         requestedUploads.add(uploadKey);
-                    } else {
-                        mUploadsStorageManager.removeUpload(newUpload.getOCUploadId());
+
+                        long id = mUploadsStorageManager.storeUpload(ocUpload);
+                        newUpload.setOCUploadId(id);
                     }
-                    // else, file already in the queue of uploads; don't repeat the request
                 }
 
             } catch (IllegalArgumentException e) {
@@ -1020,7 +1015,7 @@ public class FileUploader extends Service
         showUploadListIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
         showUploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
-                showUploadListIntent, 0));
+            showUploadListIntent, 0));
 
         mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());