From: David A. Velasco Date: Thu, 10 Jan 2013 10:39:22 +0000 (+0100) Subject: Fixed crash when uploading a file in any account after cleaning app data X-Git-Tag: oc-android-1.4.3~71 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/471bff2aecf45e0e0da6e987e2015e54f1a9672c?ds=inline Fixed crash when uploading a file in any account after cleaning app data --- diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 50baf176..568ecbcf 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -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));