- long syncDate = System.currentTimeMillis();
- if (result.isSuccess()) {
- file.setLastSyncDateForProperties(syncDate);
-
- } else {
- // file was successfully uploaded, but the new time stamp and Etag in the server could not be read;
- // just keeping old values :(
- if (!mCurrentUpload.getRemotePath().equals(file.getRemotePath())) {
- // true when the file was automatically renamed to avoid an overwrite
- OCFile newFile = new OCFile(mCurrentUpload.getRemotePath());
- newFile.setCreationTimestamp(file.getCreationTimestamp());
- newFile.setFileLength(file.getFileLength());
- newFile.setMimetype(file.getMimetype());
- newFile.setModificationTimestamp(file.getModificationTimestamp());
- newFile.setLastSyncDateForProperties(file.getLastSyncDateForProperties());
- newFile.setKeepInSync(file.keepInSync());
- // newFile.setEtag(file.getEtag()) // TODO and this is still worse
- file = newFile;
- }
+ /// maybe this would be better as part of UploadFileOperation... or maybe all this method
+ if (mCurrentUpload.wasRenamed()) {
+ OCFile oldFile = mCurrentUpload.getOldFile();
+ if (oldFile.fileExists()) {
+ oldFile.setStoragePath(null);
+ mStorageManager.saveFile(oldFile);
+
+ } // else: it was just an automatic renaming due to a name coincidence; nothing else is needed, the storagePath is right in the instance returned by mCurrentUpload.getFile()