Merge branch 'text_file_preview_pr_707_with_develop' of github.com:owncloud/android...
[pub/Android/ownCloud.git] / src / com / owncloud / android / operations / RefreshFolderOperation.java
index 8d6cfbb..977f72a 100644 (file)
@@ -39,6 +39,7 @@ import android.content.Intent;
 import android.util.Log;
 //import android.support.v4.content.LocalBroadcastManager;
 
+import com.owncloud.android.MainApp;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 
@@ -128,7 +129,7 @@ public class RefreshFolderOperation extends RemoteOperation {
      * @param   syncFullAccount         'True' means that this operation is part of a full account 
      *                                  synchronization.
      * @param   isShareSupported        'True' means that the server supports the sharing API.           
-     * @param   ignoreEtag              'True' means that the content of the remote folder should
+     * @param   ignoreETag              'True' means that the content of the remote folder should
      *                                  be fetched and updated even though the 'eTag' did not 
      *                                  change.  
      * @param   dataStorageManager      Interface with the local database.
@@ -200,7 +201,8 @@ public class RefreshFolderOperation extends RemoteOperation {
             if (mRemoteFolderChanged) {
                 result = fetchAndSyncRemoteFolder(client);
             } else {
-                mChildren = mStorageManager.getFolderContent(mLocalFolder);
+                // TODO Enable when "On Device" is recovered ?
+                mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
             }
         }
         
@@ -250,8 +252,14 @@ public class RefreshFolderOperation extends RemoteOperation {
 
             if (!mIgnoreETag) {
                 // check if remote and local folder are different
-                mRemoteFolderChanged = 
-                        !(remoteFolder.getEtag().equalsIgnoreCase(mLocalFolder.getEtag()));
+                String remoteFolderETag = remoteFolder.getEtag();
+                if (remoteFolderETag != null) {
+                    mRemoteFolderChanged =
+                            !(remoteFolderETag.equalsIgnoreCase(mLocalFolder.getEtag()));
+                } else {
+                    Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
+                            "No ETag received from server");
+                }
             }
 
             result = new RemoteOperationResult(ResultCode.OK);
@@ -340,7 +348,8 @@ public class RefreshFolderOperation extends RemoteOperation {
         List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
 
         // get current data about local contents of the folder to synchronize
-        List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder);
+        // TODO Enable when "On Device" is recovered ?
+        List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
         Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
         for (OCFile file : localFiles) {
             localFilesMap.put(file.getRemotePath(), file);
@@ -362,7 +371,7 @@ public class RefreshFolderOperation extends RemoteOperation {
             if (localFile != null) {
                 // some properties of local state are kept unmodified
                 remoteFile.setFileId(localFile.getFileId());
-                remoteFile.setKeepInSync(localFile.keepInSync());
+                remoteFile.setFavorite(localFile.isFavorite());
                 remoteFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
                 remoteFile.setModificationTimestampAtLastSyncForData(
                         localFile.getModificationTimestampAtLastSyncForData()
@@ -375,7 +384,8 @@ public class RefreshFolderOperation extends RemoteOperation {
                     remoteFile.setFileLength(localFile.getFileLength()); 
                         // TODO move operations about size of folders to FileContentProvider
                 } else if (mRemoteFolderChanged && remoteFile.isImage() &&
-                        remoteFile.getModificationTimestamp() != localFile.getModificationTimestamp()) {
+                        remoteFile.getModificationTimestamp() !=
+                                localFile.getModificationTimestamp()) {
                     remoteFile.setNeedsUpdateThumbnail(true);
                     Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
                 }
@@ -393,7 +403,7 @@ public class RefreshFolderOperation extends RemoteOperation {
             searchForLocalFileInDefaultPath(remoteFile);    // legacy   
 
             /// prepare content synchronization for kept-in-sync files
-            if (remoteFile.keepInSync()) {
+            if (remoteFile.isFavorite()) {
                 SynchronizeFileOperation operation = new SynchronizeFileOperation(  localFile,        
                                                                                     remoteFile, 
                                                                                     mAccount,