RefreshFolderOperation.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /**
  2. * ownCloud Android client application
  3. *
  4. * @author David A. Velasco
  5. * Copyright (C) 2015 ownCloud Inc.
  6. * <p>
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2,
  9. * as published by the Free Software Foundation.
  10. * <p>
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. * <p>
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.owncloud.android.operations;
  20. import android.accounts.Account;
  21. import android.content.Context;
  22. import android.content.Intent;
  23. import android.util.Log;
  24. import com.owncloud.android.datamodel.DecryptedFolderMetadata;
  25. import com.owncloud.android.datamodel.FileDataStorageManager;
  26. import com.owncloud.android.datamodel.OCFile;
  27. import com.owncloud.android.lib.common.OwnCloudClient;
  28. import com.owncloud.android.lib.common.operations.RemoteOperation;
  29. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  30. import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
  31. import com.owncloud.android.lib.common.utils.Log_OC;
  32. import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
  33. import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
  34. import com.owncloud.android.lib.resources.files.RemoteFile;
  35. import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
  36. import com.owncloud.android.lib.resources.shares.OCShare;
  37. import com.owncloud.android.syncadapter.FileSyncAdapter;
  38. import com.owncloud.android.utils.DataHolderUtil;
  39. import com.owncloud.android.utils.EncryptionUtils;
  40. import com.owncloud.android.utils.FileStorageUtils;
  41. import com.owncloud.android.utils.MimeTypeUtil;
  42. import java.util.ArrayList;
  43. import java.util.HashMap;
  44. import java.util.List;
  45. import java.util.Map;
  46. import java.util.Vector;
  47. /**
  48. * Remote operation performing the synchronization of the list of files contained
  49. * in a folder identified with its remote path.
  50. *
  51. * Fetches the list and properties of the files contained in the given folder, including their
  52. * properties, and updates the local database with them.
  53. *
  54. * Does NOT enter in the child folders to synchronize their contents also.
  55. */
  56. @SuppressWarnings("PMD.AvoidDuplicateLiterals")
  57. public class RefreshFolderOperation extends RemoteOperation {
  58. private static final String TAG = RefreshFolderOperation.class.getSimpleName();
  59. public static final String EVENT_SINGLE_FOLDER_CONTENTS_SYNCED =
  60. RefreshFolderOperation.class.getName() + ".EVENT_SINGLE_FOLDER_CONTENTS_SYNCED";
  61. public static final String EVENT_SINGLE_FOLDER_SHARES_SYNCED =
  62. RefreshFolderOperation.class.getName() + ".EVENT_SINGLE_FOLDER_SHARES_SYNCED";
  63. /** Time stamp for the synchronization process in progress */
  64. private long mCurrentSyncTime;
  65. /** Remote folder to synchronize */
  66. private OCFile mLocalFolder;
  67. /** Access to the local database */
  68. private FileDataStorageManager mStorageManager;
  69. /** Account where the file to synchronize belongs */
  70. private Account mAccount;
  71. /** Android context; necessary to send requests to the download service */
  72. private Context mContext;
  73. /** Files and folders contained in the synchronized folder after a successful operation */
  74. private List<OCFile> mChildren;
  75. /** Counter of conflicts found between local and remote files */
  76. private int mConflictsFound;
  77. /** Counter of failed operations in synchronization of kept-in-sync files */
  78. private int mFailsInKeptInSyncFound;
  79. /**
  80. * Map of remote and local paths to files that where locally stored in a location
  81. * out of the ownCloud folder and couldn't be copied automatically into it
  82. **/
  83. private Map<String, String> mForgottenLocalFiles;
  84. /**
  85. * 'True' means that this operation is part of a full account synchronization
  86. */
  87. private boolean mSyncFullAccount;
  88. /** 'True' means that Share resources bound to the files into should be refreshed also */
  89. private boolean mIsShareSupported;
  90. /** 'True' means that the remote folder changed and should be fetched */
  91. private boolean mRemoteFolderChanged;
  92. /** 'True' means that Etag will be ignored */
  93. private boolean mIgnoreETag;
  94. private List<SynchronizeFileOperation> mFilesToSyncContents;
  95. // this will be used for every file when 'folder synchronization' replaces 'folder download'
  96. /**
  97. * Creates a new instance of {@link RefreshFolderOperation}.
  98. *
  99. * @param folder Folder to synchronize.
  100. * @param currentSyncTime Time stamp for the synchronization process in progress.
  101. * @param syncFullAccount 'True' means that this operation is part of a full account
  102. * synchronization.
  103. * @param isShareSupported 'True' means that the server supports the sharing API.
  104. * @param ignoreETag 'True' means that the content of the remote folder should
  105. * be fetched and updated even though the 'eTag' did not
  106. * change.
  107. * @param dataStorageManager Interface with the local database.
  108. * @param account ownCloud account where the folder is located.
  109. * @param context Application context.
  110. */
  111. public RefreshFolderOperation(OCFile folder,
  112. long currentSyncTime,
  113. boolean syncFullAccount,
  114. boolean isShareSupported,
  115. boolean ignoreETag,
  116. FileDataStorageManager dataStorageManager,
  117. Account account,
  118. Context context) {
  119. mLocalFolder = folder;
  120. mCurrentSyncTime = currentSyncTime;
  121. mSyncFullAccount = syncFullAccount;
  122. mIsShareSupported = isShareSupported;
  123. mStorageManager = dataStorageManager;
  124. mAccount = account;
  125. mContext = context;
  126. mForgottenLocalFiles = new HashMap<String, String>();
  127. mRemoteFolderChanged = false;
  128. mIgnoreETag = ignoreETag;
  129. mFilesToSyncContents = new Vector<SynchronizeFileOperation>();
  130. }
  131. public int getConflictsFound() {
  132. return mConflictsFound;
  133. }
  134. public int getFailsInKeptInSyncFound() {
  135. return mFailsInKeptInSyncFound;
  136. }
  137. public Map<String, String> getForgottenLocalFiles() {
  138. return mForgottenLocalFiles;
  139. }
  140. /**
  141. * Returns the list of files and folders contained in the synchronized folder,
  142. * if called after synchronization is complete.
  143. *
  144. * @return List of files and folders contained in the synchronized folder.
  145. */
  146. public List<OCFile> getChildren() {
  147. return mChildren;
  148. }
  149. /**
  150. * Performs the synchronization.
  151. *
  152. * {@inheritDoc}
  153. */
  154. @Override
  155. protected RemoteOperationResult run(OwnCloudClient client) {
  156. RemoteOperationResult result = null;
  157. mFailsInKeptInSyncFound = 0;
  158. mConflictsFound = 0;
  159. mForgottenLocalFiles.clear();
  160. if (OCFile.ROOT_PATH.equals(mLocalFolder.getRemotePath()) && !mSyncFullAccount) {
  161. updateOCVersion(client);
  162. updateUserProfile();
  163. }
  164. result = checkForChanges(client);
  165. if (result.isSuccess()) {
  166. if (mRemoteFolderChanged) {
  167. result = fetchAndSyncRemoteFolder(client);
  168. } else {
  169. fetchKeptInSyncFilesToSyncFromLocalData();
  170. mChildren = mStorageManager.getFolderContent(mLocalFolder, false);
  171. }
  172. if (result.isSuccess()) {
  173. // request for the synchronization of KEPT-IN-SYNC file contents
  174. startContentSynchronizations(mFilesToSyncContents);
  175. }
  176. }
  177. if (!mSyncFullAccount) {
  178. sendLocalBroadcast(
  179. EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result
  180. );
  181. }
  182. if (result.isSuccess() && mIsShareSupported && !mSyncFullAccount) {
  183. refreshSharesForFolder(client); // share result is ignored
  184. }
  185. if (!mSyncFullAccount) {
  186. sendLocalBroadcast(
  187. EVENT_SINGLE_FOLDER_SHARES_SYNCED, mLocalFolder.getRemotePath(), result
  188. );
  189. }
  190. return result;
  191. }
  192. private void updateOCVersion(OwnCloudClient client) {
  193. UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext);
  194. RemoteOperationResult result = update.execute(client);
  195. if (result.isSuccess()) {
  196. mIsShareSupported = update.getOCVersion().isSharedSupported();
  197. // Update Capabilities for this account
  198. if (update.getOCVersion().isVersionWithCapabilitiesAPI()) {
  199. updateCapabilities();
  200. } else {
  201. Log_OC.d(TAG, "Capabilities API disabled");
  202. }
  203. }
  204. }
  205. private void updateUserProfile() {
  206. GetUserProfileOperation update = new GetUserProfileOperation();
  207. RemoteOperationResult result = update.execute(mStorageManager, mContext);
  208. if (!result.isSuccess()) {
  209. Log_OC.w(TAG, "Couldn't update user profile from server");
  210. } else {
  211. Log_OC.i(TAG, "Got display name: " + result.getData().get(0));
  212. }
  213. }
  214. private void updateCapabilities() {
  215. GetCapabilitiesOperarion getCapabilities = new GetCapabilitiesOperarion();
  216. RemoteOperationResult result = getCapabilities.execute(mStorageManager, mContext);
  217. if (!result.isSuccess()) {
  218. Log_OC.w(TAG, "Update Capabilities unsuccessfully");
  219. }
  220. }
  221. private RemoteOperationResult checkForChanges(OwnCloudClient client) {
  222. mRemoteFolderChanged = true;
  223. RemoteOperationResult result = null;
  224. String remotePath = mLocalFolder.getRemotePath();
  225. Log_OC.d(TAG, "Checking changes in " + mAccount.name + remotePath);
  226. // remote request
  227. ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
  228. result = operation.execute(client, true);
  229. if (result.isSuccess()) {
  230. OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
  231. if (!mIgnoreETag) {
  232. // check if remote and local folder are different
  233. String remoteFolderETag = remoteFolder.getEtag();
  234. if (remoteFolderETag != null) {
  235. mRemoteFolderChanged =
  236. !(remoteFolderETag.equalsIgnoreCase(mLocalFolder.getEtag()));
  237. } else {
  238. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  239. "No ETag received from server");
  240. }
  241. }
  242. result = new RemoteOperationResult(ResultCode.OK);
  243. Log_OC.i(TAG, "Checked " + mAccount.name + remotePath + " : " +
  244. (mRemoteFolderChanged ? "changed" : "not changed"));
  245. } else {
  246. // check failed
  247. if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
  248. removeLocalFolder();
  249. }
  250. if (result.isException()) {
  251. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  252. result.getLogMessage(), result.getException());
  253. } else {
  254. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  255. result.getLogMessage());
  256. }
  257. }
  258. return result;
  259. }
  260. private RemoteOperationResult fetchAndSyncRemoteFolder(OwnCloudClient client) {
  261. String remotePath = mLocalFolder.getRemotePath();
  262. ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath);
  263. RemoteOperationResult result = operation.execute(client, true);
  264. Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
  265. if (result.isSuccess()) {
  266. synchronizeData(result.getData());
  267. if (mConflictsFound > 0 || mFailsInKeptInSyncFound > 0) {
  268. result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
  269. // should be a different result code, but will do the job
  270. }
  271. } else {
  272. if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
  273. removeLocalFolder();
  274. }
  275. }
  276. return result;
  277. }
  278. private void removeLocalFolder() {
  279. if (mStorageManager.fileExists(mLocalFolder.getFileId())) {
  280. String currentSavePath = FileStorageUtils.getSavePath(mAccount.name);
  281. mStorageManager.removeFolder(
  282. mLocalFolder,
  283. true,
  284. (mLocalFolder.isDown() &&
  285. mLocalFolder.getStoragePath().startsWith(currentSavePath)
  286. )
  287. );
  288. }
  289. }
  290. /**
  291. * Synchronizes the data retrieved from the server about the contents of the target folder
  292. * with the current data in the local database.
  293. *
  294. * Grants that mChildren is updated with fresh data after execution.
  295. *
  296. * @param folderAndFiles Remote folder and children files in Folder
  297. */
  298. private void synchronizeData(ArrayList<Object> folderAndFiles) {
  299. // get 'fresh data' from the database
  300. mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
  301. // parse data from remote folder
  302. OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) folderAndFiles.get(0));
  303. remoteFolder.setParentId(mLocalFolder.getParentId());
  304. remoteFolder.setFileId(mLocalFolder.getFileId());
  305. Log_OC.d(TAG, "Remote folder " + mLocalFolder.getRemotePath()
  306. + " changed - starting update of local data ");
  307. List<OCFile> updatedFiles = new Vector<OCFile>(folderAndFiles.size() - 1);
  308. mFilesToSyncContents.clear();
  309. // if local folder is encrypted, download fresh metadata
  310. DecryptedFolderMetadata metadata;
  311. boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, mStorageManager);
  312. if (encryptedAncestor && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
  313. metadata = EncryptionUtils.downloadFolderMetadata(mLocalFolder, getClient(), mContext, mAccount);
  314. } else {
  315. metadata = null;
  316. }
  317. // get current data about local contents of the folder to synchronize
  318. List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder, false);
  319. Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
  320. for (OCFile file : localFiles) {
  321. String remotePath = file.getRemotePath();
  322. if (metadata != null && !file.isFolder()) {
  323. remotePath = file.getParentRemotePath() + file.getEncryptedFileName();
  324. }
  325. localFilesMap.put(remotePath, file);
  326. }
  327. // loop to update every child
  328. OCFile remoteFile = null;
  329. OCFile localFile = null;
  330. OCFile updatedFile = null;
  331. RemoteFile r;
  332. for (int i = 1; i < folderAndFiles.size(); i++) {
  333. /// new OCFile instance with the data from the server
  334. r = (RemoteFile) folderAndFiles.get(i);
  335. remoteFile = FileStorageUtils.fillOCFile(r);
  336. /// new OCFile instance to merge fresh data from server with local state
  337. updatedFile = FileStorageUtils.fillOCFile(r);
  338. updatedFile.setParentId(mLocalFolder.getFileId());
  339. /// retrieve local data for the read file
  340. // localFile = mStorageManager.getFileByPath(remoteFile.getRemotePath());
  341. localFile = localFilesMap.remove(remoteFile.getRemotePath());
  342. /// add to updatedFile data about LOCAL STATE (not existing in server)
  343. updatedFile.setLastSyncDateForProperties(mCurrentSyncTime);
  344. if (localFile != null) {
  345. updatedFile.setFileId(localFile.getFileId());
  346. updatedFile.setAvailableOffline(localFile.isAvailableOffline());
  347. updatedFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
  348. updatedFile.setModificationTimestampAtLastSyncForData(
  349. localFile.getModificationTimestampAtLastSyncForData()
  350. );
  351. updatedFile.setStoragePath(localFile.getStoragePath());
  352. // eTag will not be updated unless file CONTENTS are synchronized
  353. updatedFile.setEtag(localFile.getEtag());
  354. if (updatedFile.isFolder()) {
  355. updatedFile.setFileLength(remoteFile.getFileLength());
  356. } else if (mRemoteFolderChanged && MimeTypeUtil.isImage(remoteFile) &&
  357. remoteFile.getModificationTimestamp() !=
  358. localFile.getModificationTimestamp()) {
  359. updatedFile.setNeedsUpdateThumbnail(true);
  360. Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
  361. }
  362. updatedFile.setPublicLink(localFile.getPublicLink());
  363. updatedFile.setShareViaLink(localFile.isSharedViaLink());
  364. updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
  365. updatedFile.setEtagInConflict(localFile.getEtagInConflict());
  366. } else {
  367. // remote eTag will not be updated unless file CONTENTS are synchronized
  368. updatedFile.setEtag("");
  369. }
  370. /// check and fix, if needed, local storage path
  371. FileStorageUtils.searchForLocalFileInDefaultPath(updatedFile, mAccount);
  372. /// prepare content synchronization for kept-in-sync files
  373. if (updatedFile.isAvailableOffline()) {
  374. SynchronizeFileOperation operation = new SynchronizeFileOperation(localFile,
  375. remoteFile,
  376. mAccount,
  377. true,
  378. mContext
  379. );
  380. mFilesToSyncContents.add(operation);
  381. }
  382. // update file name for encrypted files
  383. if (metadata != null) {
  384. updatedFile.setEncryptedFileName(updatedFile.getFileName());
  385. try {
  386. String decryptedFileName = metadata.getFiles().get(updatedFile.getFileName()).getEncrypted()
  387. .getFilename();
  388. String mimetype = metadata.getFiles().get(updatedFile.getFileName()).getEncrypted().getMimetype();
  389. updatedFile.setFileName(decryptedFileName);
  390. if (mimetype == null || mimetype.isEmpty()) {
  391. updatedFile.setMimetype("application/octet-stream");
  392. } else {
  393. updatedFile.setMimetype(mimetype);
  394. }
  395. } catch (NullPointerException e) {
  396. Log_OC.e(TAG, "Metadata for file " + updatedFile.getFileId() + " not found!");
  397. }
  398. }
  399. boolean encrypted = FileStorageUtils.checkEncryptionStatus(updatedFile, mStorageManager);
  400. updatedFile.setEncrypted(encrypted);
  401. updatedFiles.add(updatedFile);
  402. }
  403. // save updated contents in local database
  404. mStorageManager.saveFolder(remoteFolder, updatedFiles, localFilesMap.values());
  405. mChildren = updatedFiles;
  406. }
  407. /**
  408. * Performs a list of synchronization operations, determining if a download or upload is needed
  409. * or if exists conflict due to changes both in local and remote contents of the each file.
  410. *
  411. * If download or upload is needed, request the operation to the corresponding service and goes
  412. * on.
  413. *
  414. * @param filesToSyncContents Synchronization operations to execute.
  415. */
  416. private void startContentSynchronizations(List<SynchronizeFileOperation> filesToSyncContents) {
  417. RemoteOperationResult contentsResult;
  418. for (SynchronizeFileOperation op : filesToSyncContents) {
  419. contentsResult = op.execute(mStorageManager, mContext); // async
  420. if (!contentsResult.isSuccess()) {
  421. if (contentsResult.getCode() == ResultCode.SYNC_CONFLICT) {
  422. mConflictsFound++;
  423. } else {
  424. mFailsInKeptInSyncFound++;
  425. if (contentsResult.getException() != null) {
  426. Log_OC.e(TAG, "Error while synchronizing favourites : "
  427. + contentsResult.getLogMessage(), contentsResult.getException());
  428. } else {
  429. Log_OC.e(TAG, "Error while synchronizing favourites : "
  430. + contentsResult.getLogMessage());
  431. }
  432. }
  433. } // won't let these fails break the synchronization process
  434. }
  435. }
  436. /**
  437. * Syncs the Share resources for the files contained in the folder refreshed (children, not deeper descendants).
  438. *
  439. * @param client Handler of a session with an OC server.
  440. * @return The result of the remote operation retrieving the Share resources in the folder refreshed by
  441. * the operation.
  442. */
  443. private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
  444. RemoteOperationResult result;
  445. // remote request
  446. GetRemoteSharesForFileOperation operation =
  447. new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), true, true);
  448. result = operation.execute(client);
  449. if (result.isSuccess()) {
  450. // update local database
  451. ArrayList<OCShare> shares = new ArrayList<OCShare>();
  452. for (Object obj : result.getData()) {
  453. shares.add((OCShare) obj);
  454. }
  455. mStorageManager.saveSharesInFolder(shares, mLocalFolder);
  456. }
  457. return result;
  458. }
  459. /**
  460. * Sends a message to any application component interested in the progress
  461. * of the synchronization.
  462. *
  463. * @param event
  464. * @param dirRemotePath Remote path of a folder that was just synchronized
  465. * (with or without success)
  466. * @param result
  467. */
  468. private void sendLocalBroadcast(
  469. String event, String dirRemotePath, RemoteOperationResult result
  470. ) {
  471. Log_OC.d(TAG, "Send broadcast " + event);
  472. Intent intent = new Intent(event);
  473. intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, mAccount.name);
  474. if (dirRemotePath != null) {
  475. intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath);
  476. }
  477. DataHolderUtil dataHolderUtil = DataHolderUtil.getInstance();
  478. String dataHolderItemId = dataHolderUtil.nextItemId();
  479. dataHolderUtil.save(dataHolderItemId, result);
  480. intent.putExtra(FileSyncAdapter.EXTRA_RESULT, dataHolderItemId);
  481. intent.setPackage(mContext.getPackageName());
  482. mContext.sendStickyBroadcast(intent);
  483. //LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
  484. }
  485. private void fetchKeptInSyncFilesToSyncFromLocalData() {
  486. List<OCFile> children = mStorageManager.getFolderContent(mLocalFolder, false);
  487. for (OCFile child : children) {
  488. if (!child.isFolder() && child.isAvailableOffline() && !child.isInConflict()) {
  489. SynchronizeFileOperation operation = new SynchronizeFileOperation(
  490. child,
  491. child, // cheating with the remote file to get an update to server; to refactor
  492. mAccount,
  493. true,
  494. mContext
  495. );
  496. mFilesToSyncContents.add(operation);
  497. }
  498. }
  499. }
  500. }