Bug fixed: download followed by refresh always resulted in upload, although the file...
[pub/Android/ownCloud.git] / src / com / owncloud / android / operations / SynchronizeFolderOperation.java
index 91de06e..28a2def 100644 (file)
@@ -34,6 +34,7 @@ import com.owncloud.android.datamodel.DataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileDownloader;
 import com.owncloud.android.files.services.FileObserverService;
+import com.owncloud.android.utils.FileStorageUtils;
 
 import eu.alefzero.webdav.WebdavClient;
 import eu.alefzero.webdav.WebdavEntry;
@@ -47,7 +48,7 @@ import eu.alefzero.webdav.WebdavUtils;
  */
 public class SynchronizeFolderOperation extends RemoteOperation {
 
-    private static final String TAG = SynchronizeFolderOperation.class.getCanonicalName();
+    private static final String TAG = SynchronizeFolderOperation.class.getSimpleName();
 
     /** Remote folder to synchronize */
     private String mRemotePath;
@@ -147,10 +148,10 @@ public class SynchronizeFolderOperation extends RemoteOperation {
                 // removal of obsolete files
                 mChildren = mStorageManager.getDirectoryContent(mStorageManager.getFileById(mParentId));
                 OCFile file;
-                String currentSavePath = FileDownloader.getSavePath(mAccount.name);
+                String currentSavePath = FileStorageUtils.getSavePath(mAccount.name);
                 for (int i=0; i < mChildren.size(); ) {
                     file = mChildren.get(i);
-                    if (file.getLastSyncDate() != mCurrentSyncTime) {
+                    if (file.getLastSyncDateForProperties() != mCurrentSyncTime) {
                         Log.d(TAG, "removing file: " + file);
                         mStorageManager.removeFile(file, (file.isDown() && file.getStoragePath().startsWith(currentSavePath)));
                         mChildren.remove(i);
@@ -198,7 +199,7 @@ public class SynchronizeFolderOperation extends RemoteOperation {
         file.setFileLength(we.contentLength());
         file.setMimetype(we.contentType());
         file.setModificationTimestamp(we.modifiedTimesamp());
-        file.setLastSyncDate(mCurrentSyncTime);
+        file.setLastSyncDateForProperties(mCurrentSyncTime);
         return file;
     }
     
@@ -212,7 +213,8 @@ public class SynchronizeFolderOperation extends RemoteOperation {
         Log.d(TAG, "Disabling observation of remote file" + file.getRemotePath());
         Intent intent = new Intent(mContext, FileObserverService.class);
         intent.putExtra(FileObserverService.KEY_FILE_CMD, FileObserverService.CMD_ADD_DOWNLOADING_FILE);
-        intent.putExtra(FileObserverService.KEY_CMD_ARG, file.getRemotePath());
+        intent.putExtra(FileObserverService.KEY_CMD_ARG_FILE, file);
+        intent.putExtra(FileObserverService.KEY_CMD_ARG_ACCOUNT, mAccount);
         mContext.startService(intent);
         
     }