private OCFile mFile;
private Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
private long mModificationTimestamp = 0;
+ private String mEtag = "";
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
private DownloadRemoteFileOperation mDownloadOperation;
public DownloadFileOperation(Account account, OCFile file) {
if (account == null)
- throw new IllegalArgumentException("Illegal null account in DownloadFileOperation creation");
+ throw new IllegalArgumentException("Illegal null account in DownloadFileOperation " +
+ "creation");
if (file == null)
- throw new IllegalArgumentException("Illegal null file in DownloadFileOperation creation");
+ throw new IllegalArgumentException("Illegal null file in DownloadFileOperation " +
+ "creation");
mAccount = account;
mFile = file;
}
public String getSavePath() {
- String path = mFile.getStoragePath(); // re-downloads should be done over the original file
+ String path = mFile.getStoragePath(); // re-downloads should be done over the original file
if (path != null && path.length() > 0) {
return path;
}
try {
mimeType = MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(
- mFile.getRemotePath().substring(mFile.getRemotePath().lastIndexOf('.') + 1));
+ mFile.getRemotePath().substring(
+ mFile.getRemotePath().lastIndexOf('.') + 1));
} catch (IndexOutOfBoundsException e) {
- Log_OC.e(TAG, "Trying to find out MIME type of a file without extension: " + mFile.getRemotePath());
+ Log_OC.e(TAG, "Trying to find out MIME type of a file without extension: " +
+ mFile.getRemotePath());
}
}
if (mimeType == null) {
}
public long getModificationTimestamp() {
- return (mModificationTimestamp > 0) ? mModificationTimestamp : mFile.getModificationTimestamp();
+ return (mModificationTimestamp > 0) ? mModificationTimestamp :
+ mFile.getModificationTimestamp();
+ }
+
+ public String getEtag() {
+ return mEtag;
}
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
- RemoteOperationResult result = null;
- File newFile = null;
- boolean moved = true;
+ RemoteOperationResult result;
+ File newFile;
+ boolean moved;
/// download will be performed to a temporal file, then moved to the final location
File tmpFile = new File(getTmpPath());
if (result.isSuccess()) {
mModificationTimestamp = mDownloadOperation.getModificationTimestamp();
+ mEtag = mDownloadOperation.getEtag();
newFile = new File(getSavePath());
newFile.getParentFile().mkdirs();
moved = tmpFile.renameTo(newFile);
if (!moved)
- result = new RemoteOperationResult(RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);
+ result = new RemoteOperationResult(
+ RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);
}
- Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " + result.getLogMessage());
+ Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " +
+ result.getLogMessage());
return result;
}