cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
- cv.put(ProviderTableMeta.FILE_IN_CONFLICT, file.isInConflict());
+ cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
boolean sameRemotePath = fileExists(file.getRemotePath());
if (sameRemotePath || fileExists(file.getFileId())) { // for renamed files; no more delete and create
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
- cv.put(ProviderTableMeta.FILE_IN_CONFLICT, file.isInConflict());
+ cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
boolean existsByPath = fileExists(file.getRemotePath());
if (existsByPath || fileExists(file.getFileId())) {
// maybe unnecessary, but should be checked TODO remove if unnecessary
file.setStoragePath(null);
saveFile(file);
- saveConflict(file, false);
+ saveConflict(file, null);
}
}
}
c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1 ? true : false);
file.setDownloading(c.getInt(
c.getColumnIndex(ProviderTableMeta.FILE_IS_DOWNLOADING)) == 1 ? true : false);
- file.setInConflict(c.getInt(
- c.getColumnIndex(ProviderTableMeta.FILE_IN_CONFLICT)) == 1 ? true : false);
+ file.setEtagInConflict(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG_IN_CONFLICT)));
}
return file;
ProviderTableMeta.FILE_IS_DOWNLOADING,
file.isDownloading() ? 1 : 0
);
- cv.put(
- ProviderTableMeta.FILE_IN_CONFLICT,
- file.isInConflict() ? 1 : 0
- );
+ cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
boolean existsByPath = fileExists(file.getRemotePath());
if (existsByPath || fileExists(file.getFileId())) {
}
- public void saveConflict(OCFile file, boolean inConflict) {
+ public void saveConflict(OCFile file, String etagInConflict) {
if (!file.isDown()) {
- inConflict = false;
+ etagInConflict = null;
}
ContentValues cv = new ContentValues();
- cv.put(ProviderTableMeta.FILE_IN_CONFLICT, inConflict ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict);
int updated = 0;
if (getContentResolver() != null) {
updated = getContentResolver().update(
Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated);
if (updated > 0) {
- if (inConflict) {
+ if (etagInConflict != null) {
/// set conflict in all ancestor folders
long parentId = file.getParentId();
while (parentPath.length() > 0) {
String where =
- ProviderTableMeta.FILE_IN_CONFLICT + " = 1 AND " +
+ ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " IS NOT NULL AND " +
ProviderTableMeta.FILE_CONTENT_TYPE + " != 'DIR' AND " +
ProviderTableMeta.FILE_ACCOUNT_OWNER + " = ? AND " +
ProviderTableMeta.FILE_PATH + " LIKE ?";
updated = getContentResolver().update(
ProviderTableMeta.CONTENT_URI_FILE,
cv,
- ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + "=?",
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
+ ProviderTableMeta.FILE_PATH + "=?",
new String[]{mAccount.name, parentPath}
);
} else {
updated = getContentProviderClient().update(
ProviderTableMeta.CONTENT_URI_FILE,
cv,
- ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + "=?"
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
+ ProviderTableMeta.FILE_PATH + "=?"
, new String[]{mAccount.name, parentPath}
);
} catch (RemoteException e) {
private boolean mIsDownloading;
- private boolean mInConflict;
+ private String mEtagInConflict; // Save file etag in the server, when there is a conflict. No conflict = null
/**
mRemoteId = source.readString();
mNeedsUpdateThumbnail = source.readInt() == 1;
mIsDownloading = source.readInt() == 1;
- mInConflict = source.readInt() == 1;
+ mEtagInConflict = source.readString();
}
dest.writeString(mRemoteId);
dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0);
dest.writeInt(mIsDownloading ? 1 : 0);
- dest.writeInt(mInConflict ? 1 : 0);
+ dest.writeString(mEtagInConflict);
}
/**
mRemoteId = null;
mNeedsUpdateThumbnail = false;
mIsDownloading = false;
- mInConflict = false;
+ mEtagInConflict = null;
}
/**
this.mIsDownloading = isDownloading;
}
- public boolean isInConflict() {
- return mInConflict;
+ public String getEtagInConflict() {
+ return mEtagInConflict;
}
- public void setInConflict(boolean inConflict) {
- mInConflict = inConflict;
+ public void setEtagInConflict(String etagInConflict) {
+ mEtagInConflict = etagInConflict;
}
}
public static final String FILE_REMOTE_ID = "remote_id";\r
public static final String FILE_UPDATE_THUMBNAIL = "update_thumbnail";\r
public static final String FILE_IS_DOWNLOADING= "is_downloading";\r
- public static final String FILE_IN_CONFLICT = "in_conflict";\r
+ public static final String FILE_ETAG_IN_CONFLICT = "etag_in_conflict";\r
\r
public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME\r
+ " collate nocase asc";\r
file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
mStorageManager.saveFile(file);
mStorageManager.triggerMediaScan(file.getStoragePath());
- mStorageManager.saveConflict(file, false);
+ mStorageManager.saveConflict(file, null);
}
/**
saveUploadedFile();
} else if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) {
- mStorageManager.saveConflict(mCurrentUpload.getFile(), true);
+ mStorageManager.saveConflict(mCurrentUpload.getFile(),
+ mCurrentUpload.getFile().getEtagInConflict());
}
} else {
uploadResult = grantResult;
if (oldFile.fileExists()) {
oldFile.setStoragePath(null);
mStorageManager.saveFile(oldFile);
- mStorageManager.saveConflict(oldFile, false);
+ mStorageManager.saveConflict(oldFile, null);
} // else: it was just an automatic renaming due to a name
// coincidence; nothing else is needed, the storagePath is right
}
file.setNeedsUpdateThumbnail(true);
mStorageManager.saveFile(file);
- mStorageManager.saveConflict(file, false);
+ mStorageManager.saveConflict(file, null);
mStorageManager.triggerMediaScan(file.getStoragePath());
}
updatedFile.setPublicLink(localFile.getPublicLink());
updatedFile.setShareByLink(localFile.isShareByLink());
- updatedFile.setInConflict(localFile.isInConflict());
+ updatedFile.setEtagInConflict(localFile.getEtagInConflict());
} else {
// remote eTag will not be updated unless file CONTENTS are synchronized
updatedFile.setEtag("");
//if (!mLocalFile.getEtag().isEmpty() && localChanged && serverChanged) {
if (localChanged && serverChanged) {
result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
- getStorageManager().saveConflict(mLocalFile, true);
+ getStorageManager().saveConflict(mLocalFile, mServerFile.getEtag());
} else if (localChanged) {
if (mSyncFileContents && mAllowUploads) {
// safe blanket: sync'ing a not in-conflict file will clean wrong conflict markers in ancestors
if (result.getCode() != ResultCode.SYNC_CONFLICT) {
- getStorageManager().saveConflict(mLocalFile, false);
+ getStorageManager().saveConflict(mLocalFile, null);
}
}
}
updatedFile.setPublicLink(localFile.getPublicLink());
updatedFile.setShareByLink(localFile.isShareByLink());
- updatedFile.setInConflict(localFile.isInConflict());
+ updatedFile.setEtagInConflict(localFile.getEtagInConflict());
} else {
// remote eTag will not be updated unless file CONTENTS are synchronized
updatedFile.setEtag("");
/// this should result in direct upload of files that were locally modified
SynchronizeFileOperation operation = new SynchronizeFileOperation(
child,
- (child.isInConflict() ? null : child),
+ (child.getEtagInConflict() != null ? null : child),
mAccount,
true,
mContext
(new File(mFile.getStoragePath())).length() >
ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) {
mUploadOperation = new ChunkedUploadRemoteFileOperation(mFile.getStoragePath(),
- mFile.getRemotePath(), mFile.getMimetype(), mFile.getEtag());
+ mFile.getRemotePath(), mFile.getMimetype(), mFile.getEtagInConflict());
} else {
mUploadOperation = new UploadRemoteFileOperation(mFile.getStoragePath(),
- mFile.getRemotePath(), mFile.getMimetype(), mFile.getEtag());
+ mFile.getRemotePath(), mFile.getMimetype(), mFile.getEtagInConflict());
}
Iterator <OnDatatransferProgressListener> listener = mDataTransferListeners.iterator();
while (listener.hasNext()) {
ProviderTableMeta.FILE_UPDATE_THUMBNAIL);
mFileProjectionMap.put(ProviderTableMeta.FILE_IS_DOWNLOADING,
ProviderTableMeta.FILE_IS_DOWNLOADING);
- mFileProjectionMap.put(ProviderTableMeta.FILE_IN_CONFLICT,
- ProviderTableMeta.FILE_IN_CONFLICT);
+ mFileProjectionMap.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT,
+ ProviderTableMeta.FILE_ETAG_IN_CONFLICT);
}
private static final int SINGLE_FILE = 1;
+ ProviderTableMeta.FILE_REMOTE_ID + " TEXT null,"
+ ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER," //boolean
+ ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER," //boolean
- + ProviderTableMeta.FILE_IN_CONFLICT + " INTEGER);" //boolean
+ + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT);"
);
// Create table ocshares
db.beginTransaction();
try {
db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
- " ADD COLUMN " + ProviderTableMeta.FILE_IN_CONFLICT + " INTEGER " +
- " DEFAULT 0");
+ " ADD COLUMN " + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT " +
+ " DEFAULT NULL");
upgraded = true;
db.setTransactionSuccessful();
} finally {
);\r
localStateView.setVisibility(View.VISIBLE);\r
\r
- } else if (file.isInConflict()) { // conflict\r
+ } else if (file.getEtagInConflict() != null) { // conflict\r
localStateView.setImageResource(R.drawable.conflict_file_indicator);\r
localStateView.setVisibility(View.VISIBLE);\r
\r