projects
/
pub
/
Android
/
ownCloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed local path NULL when making favourite a file not down ; fixed change of local...
[pub/Android/ownCloud.git]
/
src
/
com
/
owncloud
/
android
/
datamodel
/
FileDataStorageManager.java
diff --git
a/src/com/owncloud/android/datamodel/FileDataStorageManager.java
b/src/com/owncloud/android/datamodel/FileDataStorageManager.java
index
49a88c3
..
ca18940
100644
(file)
--- a/
src/com/owncloud/android/datamodel/FileDataStorageManager.java
+++ b/
src/com/owncloud/android/datamodel/FileDataStorageManager.java
@@
-27,7
+27,7
@@
import java.util.Vector;
import com.owncloud.android.db.ProviderMeta;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import com.owncloud.android.db.ProviderMeta;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
-import com.owncloud.android.
files.services.FileDownloader
;
+import com.owncloud.android.
utils.FileStorageUtils
;
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.accounts.Account;
import android.content.ContentProviderClient;
@@
-38,7
+38,6
@@
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.net.Uri;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Environment;
import android.os.RemoteException;
import android.util.Log;
import android.os.RemoteException;
import android.util.Log;
@@
-72,7
+71,7
@@
public class FileDataStorageManager implements DataStorageManager {
c.close();
return file;
}
c.close();
return file;
}
-
+
@Override
public OCFile getFileById(long id) {
Cursor c = getCursorForValue(ProviderTableMeta._ID, String.valueOf(id));
@Override
public OCFile getFileById(long id) {
Cursor c = getCursorForValue(ProviderTableMeta._ID, String.valueOf(id));
@@
-83,6
+82,16
@@
public class FileDataStorageManager implements DataStorageManager {
c.close();
return file;
}
c.close();
return file;
}
+
+ public OCFile getFileByLocalPath(String path) {
+ Cursor c = getCursorForValue(ProviderTableMeta.FILE_STORAGE_PATH, path);
+ OCFile file = null;
+ if (c.moveToFirst()) {
+ file = createFileInstance(c);
+ }
+ c.close();
+ return file;
+ }
@Override
public boolean fileExists(long id) {
@Override
public boolean fileExists(long id) {
@@
-269,6
+278,7
@@
public class FileDataStorageManager implements DataStorageManager {
return mContentProvider;
}
return mContentProvider;
}
+ @Override
public Vector<OCFile> getDirectoryContent(OCFile f) {
if (f != null && f.isDirectory() && f.getFileId() != -1) {
Vector<OCFile> ret = new Vector<OCFile>();
public Vector<OCFile> getDirectoryContent(OCFile f) {
if (f != null && f.isDirectory() && f.getFileId() != -1) {
Vector<OCFile> ret = new Vector<OCFile>();
@@
-380,7
+390,7
@@
public class FileDataStorageManager implements DataStorageManager {
.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
if (file.getStoragePath() == null) {
// try to find existing file and bind it with current account
.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
if (file.getStoragePath() == null) {
// try to find existing file and bind it with current account
- File f = new File(File
Downloader.getSavePath(mAccount.name) + file.getRemotePath(
));
+ File f = new File(File
StorageUtils.getDefaultSavePathFor(mAccount.name, file
));
if (f.exists())
file.setStoragePath(f.getAbsolutePath());
}
if (f.exists())
file.setStoragePath(f.getAbsolutePath());
}
@@
-399,7
+409,8
@@
public class FileDataStorageManager implements DataStorageManager {
return file;
}
return file;
}
- public void removeFile(OCFile file) {
+ @Override
+ public void removeFile(OCFile file, boolean removeLocalCopy) {
Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
if (getContentProvider() != null) {
try {
Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
if (getContentProvider() != null) {
try {
@@
-414,7
+425,7
@@
public class FileDataStorageManager implements DataStorageManager {
ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
new String[]{mAccount.name});
}
ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
new String[]{mAccount.name});
}
- if (file.isDown()) {
+ if (file.isDown()
&& removeLocalCopy
) {
new File(file.getStoragePath()).delete();
}
}
new File(file.getStoragePath()).delete();
}
}