Fixed crash when uploading a file in any account after cleaning app data

This commit is contained in:
David A. Velasco 2013-01-10 11:39:22 +01:00
parent afa58b8ac6
commit 471bff2aec

View file

@ -46,9 +46,9 @@ public class FileDataStorageManager implements DataStorageManager {
private ContentResolver mContentResolver;
private ContentProviderClient mContentProvider;
private Account mAccount;
private static String TAG = "FileDataStorageManager";
public FileDataStorageManager(Account account, ContentResolver cr) {
mContentProvider = null;
mContentResolver = cr;
@ -69,9 +69,21 @@ public class FileDataStorageManager implements DataStorageManager {
file = createFileInstance(c);
}
c.close();
if (file == null && OCFile.PATH_SEPARATOR.equals(path)) {
return createRootDir(); // root should always exist
}
return file;
}
private OCFile createRootDir() {
OCFile file = new OCFile(OCFile.PATH_SEPARATOR);
file.setMimetype("DIR");
file.setParentId(DataStorageManager.ROOT_PARENT_ID);
saveFile(file);
return file;
}
@Override
public OCFile getFileById(long id) {
Cursor c = getCursorForValue(ProviderTableMeta._ID, String.valueOf(id));