Fixes #389 app crash when file deleted during auto upload
This commit is contained in:
parent
d5486463a8
commit
c3278b3c25
@ -0,0 +1,7 @@
|
||||
package org.cryptomator.domain.exception;
|
||||
|
||||
public class FileRemovedDuringUploadException extends BackendException {
|
||||
|
||||
public FileRemovedDuringUploadException() {
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ import org.cryptomator.domain.exception.BackendException;
|
||||
import org.cryptomator.domain.exception.CancellationException;
|
||||
import org.cryptomator.domain.exception.CloudNodeAlreadyExistsException;
|
||||
import org.cryptomator.domain.exception.FatalBackendException;
|
||||
import org.cryptomator.domain.exception.FileRemovedDuringUploadException;
|
||||
import org.cryptomator.domain.exception.MissingCryptorException;
|
||||
import org.cryptomator.domain.exception.NoSuchCloudFileException;
|
||||
import org.cryptomator.domain.repository.CloudContentRepository;
|
||||
@ -182,7 +183,11 @@ public class AutoUploadService extends Service {
|
||||
} catch (CloudNodeAlreadyExistsException e) {
|
||||
Timber.tag("AutoUploadService").i("Not uploading file because it already exists in the cloud");
|
||||
Timber.tag("AutoUploadService").v(format("Not uploading file because it already exists in the cloud %s", file.getFileName()));
|
||||
} catch (Exception e) {
|
||||
} catch (FileRemovedDuringUploadException e) {
|
||||
Timber.tag("AutoUploadService").i("Not uploading file because it was removed during upload");
|
||||
Timber.tag("AutoUploadService").v(format("Not uploading file because it was removed during upload %s", file.getFileName()));
|
||||
}
|
||||
catch (Exception e) {
|
||||
cancelled = true;
|
||||
fileUtil.removeImagesFromAutoUploads(uploadedCloudFileNames);
|
||||
throw e;
|
||||
@ -211,6 +216,9 @@ public class AutoUploadService extends Service {
|
||||
|
||||
private CloudFile writeCloudFile(String fileName, CancelAwareDataSource dataSource, boolean replacing, ProgressAware<UploadState> progressAware) throws BackendException {
|
||||
Long size = dataSource.size(context);
|
||||
if(size == null) {
|
||||
throw new FileRemovedDuringUploadException();
|
||||
}
|
||||
CloudFile source = cloudContentRepository.file(parent, fileName, size);
|
||||
return cloudContentRepository.write(source, dataSource, progressAware, replacing, size);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user