import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
+import android.os.Environment;
import android.os.RemoteException;
import android.util.Log;
if (file.getParentId() != 0)
cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
- cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
+ if (!file.isDirectory())
+ cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDate());
if (fileExists(file.getRemotePath())) {
OCFile tmpfile = getFileByPath(file.getRemotePath());
file.setStoragePath(tmpfile.getStoragePath());
- cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
+ if (!file.isDirectory());
+ cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
file.setFileId(tmpfile.getFileId());
overriden = true;
file.setFileId(c.getLong(c.getColumnIndex(ProviderTableMeta._ID)));
file.setParentId(c.getLong(c
.getColumnIndex(ProviderTableMeta.FILE_PARENT)));
- file.setStoragePath(c.getString(c
- .getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
file.setMimetype(c.getString(c
.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)));
+ if (!file.isDirectory()) {
+ file.setStoragePath(c.getString(c
+ .getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
+ if (file.getStoragePath() == null) {
+ // try to find exisiting file and bind it with current account
+ File sdCard = Environment.getExternalStorageDirectory();
+ File f = new File(sdCard.getAbsolutePath() + "/owncloud/" + mAccount.name + file.getRemotePath());
+ if (f.exists())
+ file.setStoragePath(f.getAbsolutePath());
+ }
+ }
file.setFileLength(c.getLong(c
.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH)));
file.setCreationTimestamp(c.getLong(c