Bläddra i källkod

OC-673: Show folder size at a first sync

masensio 11 år sedan
förälder
incheckning
5f0dfa61ab

+ 14 - 3
src/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -235,6 +235,12 @@ public class FileDataStorageManager implements DataStorageManager {
             if (fileExists(file.getRemotePath())) {
                 OCFile oldFile = getFileByPath(file.getRemotePath());
                 file.setFileId(oldFile.getFileId());
+               
+                if (file.isDirectory()) {
+                    cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength());
+                    file.setFileLength(oldFile.getFileLength());
+                }
+                
                 operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
                         withValues(cv).
                         withSelection(  ProviderTableMeta._ID + "=?", 
@@ -245,9 +251,14 @@ public class FileDataStorageManager implements DataStorageManager {
                 OCFile oldFile = getFileById(file.getFileId());
                 if (file.getStoragePath() == null && oldFile.getStoragePath() != null)
                     file.setStoragePath(oldFile.getStoragePath());
-                if (!file.isDirectory());
-                cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
-
+                
+                if (!file.isDirectory())
+                    cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
+                else {
+                    cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength());
+                    file.setFileLength(oldFile.getFileLength());
+                }
+                
                 operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
                         withValues(cv).
                         withSelection(  ProviderTableMeta._ID + "=?", 

+ 3 - 1
src/com/owncloud/android/syncadapter/FileSyncAdapter.java

@@ -220,6 +220,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             List<OCFile> children = synchFolderOp.getChildren();
             fetchChildren(children);    // beware of the 'hidden' recursion here!
             
+            sendStickyBroadcast(true, remotePath, null);
+            
         } else {
             if (result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED) {
                 mSyncResult.stats.numAuthExceptions++;
@@ -267,7 +269,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
                 fetchData(newFile.getRemotePath(), newFile.getFileId());
                 
                 // Update folder size on DB
-                getStorageManager().calculateFolderSize(newFile.getFileId());       
+                getStorageManager().calculateFolderSize(newFile.getFileId());                   
             }
         }