+ String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile); /// not before getAvailableRemotePath() !!!
+ expectedFile = new File(expectedPath);
+
+ /// check location of local file; if not the expected, copy to a temporal file before upload (if COPY is the expected behaviour)
+ if (!originalStoragePath.equals(expectedPath) && mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY) {
+
+ File ocLocalFolder = new File(FileStorageUtils.getSavePath(mAccount.name));
+ if (ocLocalFolder.getUsableSpace() < originalFile.length()) {
+ result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_FULL);
+ return result; // error condition when the file should be copied
+
+ } else {
+ String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
+ mFile.setStoragePath(temporalPath);
+ temporalFile = new File(temporalPath);
+ if (!originalStoragePath.equals(temporalPath)) { // preventing weird but possible situation
+ InputStream in = new FileInputStream(originalFile);
+ OutputStream out = new FileOutputStream(temporalFile);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0){
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+ }
+ }
+ localCopyPassed = true;
+