Fix sd card stuff

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-07-26 13:59:10 +02:00 committed by AndyScherzinger
parent 158b12df71
commit fc3e981fe7
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -414,8 +414,28 @@ public class UploadFileOperation extends SyncOperation {
throw new OperationCancelledException();
}
FileChannel channel = new RandomAccessFile(mFile.getStoragePath(), "rw").getChannel();
fileLock = channel.tryLock();
FileChannel channel = null;
try {
channel = new RandomAccessFile(mFile.getStoragePath(), "rw").getChannel();
fileLock = channel.tryLock();
} catch (FileNotFoundException e) {
if (temporalFile == null) {
String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
mFile.setStoragePath(temporalPath);
temporalFile = new File(temporalPath);
result = copy(originalFile, temporalFile);
if (result != null) {
return result;
} else {
channel = new RandomAccessFile(temporalFile.getAbsolutePath(), "rw").getChannel();
fileLock = channel.tryLock();
}
} else {
channel = new RandomAccessFile(temporalFile.getAbsolutePath(), "rw").getChannel();
fileLock = channel.tryLock();
}
}
result = mUploadOperation.execute(client);