- getStorageManager().saveFile(mFile);
- }
-
- /**
- * Checks if the new name to set is valid in the file system
- *
- * The only way to be sure is trying to create a file with that name. It's made in the temporal directory
- * for downloads, out of any account, and then removed.
- *
- * IMPORTANT: The test must be made in the same file system where files are download. The internal storage
- * could be formatted with a different file system.
- *
- * TODO move this method, and maybe FileDownload.get***Path(), to a class with utilities specific for the interactions with the file system
- *
- * @return 'True' if a temporal file named with the name to set could be created in the file system where
- * local files are stored.
- * @throws IOException When the temporal folder can not be created.
- */
- private boolean isValidNewName() throws IOException {
- // check tricky names
- if (mNewName == null || mNewName.length() <= 0 || mNewName.contains(File.separator) || mNewName.contains("%")) {
- return false;
- }
- // create a test file
- String tmpFolderName = FileStorageUtils.getTemporalPath("");
- File testFile = new File(tmpFolderName + mNewName);
- File tmpFolder = testFile.getParentFile();
- tmpFolder.mkdirs();
- if (!tmpFolder.isDirectory()) {
- throw new IOException("Unexpected error: temporal directory could not be created");
- }
- try {
- testFile.createNewFile(); // return value is ignored; it could be 'false' because the file already existed, that doesn't invalidate the name
- } catch (IOException e) {
- Log_OC.i(TAG, "Test for validity of name " + mNewName + " in the file system failed");
- return false;
- }
- boolean result = (testFile.exists() && testFile.isFile());
-
- // cleaning ; result is ignored, since there is not much we could do in case of failure, but repeat and repeat...
- testFile.delete();
+ /// 3. local move
+ if (result.isSuccess()) {
+ getStorageManager().moveLocalFile(mFile, targetPath, mTargetParentPath);
+ }
+ // TODO handle ResultCode.PARTIAL_MOVE_DONE in client Activity, for the moment