From: Bartek Przybylski Date: Wed, 23 May 2012 20:43:15 +0000 (+0200) Subject: merge fix X-Git-Tag: oc-android-1.4.3~390^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/3951aa97f0ff08ad62404822a3bab9986ef8c747?ds=inline;hp=-c merge fix --- 3951aa97f0ff08ad62404822a3bab9986ef8c747 diff --combined src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java index a47b7de7,e0870b99..3733234a --- a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java +++ b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java @@@ -18,8 -18,6 +18,8 @@@ package eu.alefzero.owncloud.datamodel; +import java.io.File; +import java.util.Collections; import java.util.Vector; import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta; @@@ -95,13 -93,13 +95,13 @@@ public class FileDataStorageManager imp cv.put(ProviderTableMeta.FILE_NAME, file.getFileName()); if (file.getParentId() != 0) cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId()); - cv.put(ProviderTableMeta.FILE_PATH, file.getPath()); + cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath()); 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.getPath())) { - OCFile tmpfile = getFileByPath(file.getPath()); + if (fileExists(file.getRemotePath())) { + OCFile tmpfile = getFileByPath(file.getRemotePath()); file.setStoragePath(tmpfile.getStoragePath()); cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); file.setFileId(tmpfile.getFileId()); @@@ -207,9 -205,6 +207,9 @@@ } c.close(); + + Collections.sort(ret); + return ret; } return null; @@@ -310,9 -305,6 +310,9 @@@ ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?", new String[]{mAccount.name}); } + if (file.getStoragePath() != null) { + new File(file.getStoragePath()).delete(); + } } } diff --combined src/eu/alefzero/owncloud/datamodel/OCFile.java index b087a9df,9566a193..336f95c3 --- a/src/eu/alefzero/owncloud/datamodel/OCFile.java +++ b/src/eu/alefzero/owncloud/datamodel/OCFile.java @@@ -23,7 -23,7 +23,7 @@@ import java.io.File import android.os.Parcel; import android.os.Parcelable; -public class OCFile implements Parcelable { +public class OCFile implements Parcelable, Comparable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override @@@ -86,11 -86,11 +86,11 @@@ } /** - * Returns the path of the file + * Returns the remote path of the file on ownCloud * - * @return The path + * @return The remote path to the file */ - public String getPath() { + public String getRemotePath() { return mRemotePath; } @@@ -119,7 -119,7 +119,7 @@@ * @return true if it is */ public boolean isDownloaded() { - return mLocalPath != null || mLocalPath.equals(""); + return mLocalPath != null && !mLocalPath.equals(""); } /** @@@ -322,15 -322,18 +322,27 @@@ } @Override + public int compareTo(OCFile another) { + if (isDirectory() && another.isDirectory()) { + return getFileName().toLowerCase().compareTo(another.getFileName().toLowerCase()); + } else if (isDirectory()) { + return -1; + } else if (another.isDirectory()) { + return 1; + } + return getFileName().toLowerCase().compareTo(another.getFileName().toLowerCase()); + } + + public boolean equals(Object o) { + OCFile that = (OCFile) o; + return this.mId == that.mId; + } + + @Override + public String toString() { + String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s]"; + asString = String.format(asString, new Long(mId), getFileName(), mMimeType, isDownloaded(), mLocalPath, mRemotePath); + return asString; + } - - + }