From: masensio Date: Thu, 3 Dec 2015 11:50:01 +0000 (+0100) Subject: Merge branch 'stable' X-Git-Tag: sd-android-1.9^2~5 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/d0b5d397c44e9d3fbae2ad946137e925bbc91cb7?hp=210298befa8b8ac4152c816dc1f97201911328c1 Merge branch 'stable' --- diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 805e9ce7..d8eb6c82 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -19,8 +19,8 @@ --> + android:versionCode="10900000" + android:versionName="1.9.0" > - - - + android:versionCode="0100026" + android:versionName="1.0.26" > 0) { - String where = + String whereForDescencentsInConflict = ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " IS NOT NULL AND " + ProviderTableMeta.FILE_CONTENT_TYPE + " != 'DIR' AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + " = ? AND " + ProviderTableMeta.FILE_PATH + " LIKE ?"; - Cursor descendentsInConflict = getContentResolver().query( - ProviderTableMeta.CONTENT_URI_FILE, - new String[]{ProviderTableMeta._ID}, - where, - new String[]{mAccount.name, parentPath + "%"}, - null - ); + Cursor descendentsInConflict = null; + if (getContentResolver() != null) { + descendentsInConflict = getContentResolver().query( + ProviderTableMeta.CONTENT_URI_FILE, + new String[]{ProviderTableMeta._ID}, + whereForDescencentsInConflict, + new String[]{mAccount.name, parentPath + "%"}, + null + ); + } else { + try { + descendentsInConflict = getContentProviderClient().query( + ProviderTableMeta.CONTENT_URI_FILE, + new String[]{ProviderTableMeta._ID}, + whereForDescencentsInConflict, + new String[]{mAccount.name, parentPath + "%"}, + null + ); + } catch (RemoteException e) { + Log_OC.e(TAG, "Failed querying for descendents in conflict " + e.getMessage()); + } + } if (descendentsInConflict == null || descendentsInConflict.getCount() == 0) { Log_OC.d(TAG, "NO MORE conflicts in " + parentPath); if (getContentResolver() != null) { diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index f0ecf767..4ad73173 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -278,12 +278,13 @@ public class ThumbnailsCacheManager { OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount); if (mClient != null && serverOCVersion != null) { if (serverOCVersion.supportsRemoteThumbnails()) { + GetMethod get = null; try { String uri = mClient.getBaseUri() + "" + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px + Uri.encode(file.getRemotePath(), "/"); Log_OC.d("Thumbnail", "URI: " + uri); - GetMethod get = new GetMethod(uri); + get = new GetMethod(uri); int status = mClient.executeMethod(get); if (status == HttpStatus.SC_OK) { InputStream inputStream = get.getResponseBodyAsStream(); @@ -299,9 +300,15 @@ public class ThumbnailsCacheManager { if (thumbnail != null) { addBitmapToCache(imageKey, thumbnail); } + } else { + mClient.exhaustResponse(get.getResponseBodyAsStream()); } } catch (Exception e) { e.printStackTrace(); + } finally { + if (get != null) { + get.releaseConnection(); + } } } else { Log_OC.d(TAG, "Server too old"); diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index b6f21a5c..513a639f 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -174,10 +174,11 @@ public class FileDownloader extends Service Pair putResult = mPendingDownloads.putIfAbsent( account, file.getRemotePath(), newDownload ); - String downloadKey = putResult.first; - requestedDownloads.add(downloadKey); - - sendBroadcastNewDownload(newDownload, putResult.second); + if (putResult != null) { + String downloadKey = putResult.first; + requestedDownloads.add(downloadKey); + sendBroadcastNewDownload(newDownload, putResult.second); + } // else, file already in the queue of downloads; don't repeat the request } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 7c953b84..5c2cd1e4 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -299,8 +299,10 @@ public class FileUploader extends Service Pair putResult = mPendingUploads.putIfAbsent( account, files[i].getRemotePath(), newUpload ); - uploadKey = putResult.first; - requestedUploads.add(uploadKey); + if (putResult != null) { + uploadKey = putResult.first; + requestedUploads.add(uploadKey); + } // else, file already in the queue of uploads; don't repeat the request } } catch (IllegalArgumentException e) { diff --git a/src/com/owncloud/android/files/services/IndexedForest.java b/src/com/owncloud/android/files/services/IndexedForest.java index 4c1ac7bd..8f4ccb67 100644 --- a/src/com/owncloud/android/files/services/IndexedForest.java +++ b/src/com/owncloud/android/files/services/IndexedForest.java @@ -101,38 +101,45 @@ public class IndexedForest { public /* synchronized */ Pair putIfAbsent(Account account, String remotePath, V value) { String targetKey = buildKey(account, remotePath); Node valuedNode = new Node(targetKey, value); - mMap.putIfAbsent( - targetKey, - valuedNode + Node previousValue = mMap.putIfAbsent( + targetKey, + valuedNode ); + if (previousValue != null) { + // remotePath already known; not replaced + return null; - String currentPath = remotePath, parentPath = null, parentKey = null; - Node currentNode = valuedNode, parentNode = null; - boolean linked = false; - while (!OCFile.ROOT_PATH.equals(currentPath) && !linked) { - parentPath = new File(currentPath).getParent(); - if (!parentPath.endsWith(OCFile.PATH_SEPARATOR)) { - parentPath += OCFile.PATH_SEPARATOR; + } else { + // value really added + String currentPath = remotePath, parentPath = null, parentKey = null; + Node currentNode = valuedNode, parentNode = null; + boolean linked = false; + while (!OCFile.ROOT_PATH.equals(currentPath) && !linked) { + parentPath = new File(currentPath).getParent(); + if (!parentPath.endsWith(OCFile.PATH_SEPARATOR)) { + parentPath += OCFile.PATH_SEPARATOR; + } + parentKey = buildKey(account, parentPath); + parentNode = mMap.get(parentKey); + if (parentNode == null) { + parentNode = new Node(parentKey, null); + parentNode.addChild(currentNode); + mMap.put(parentKey, parentNode); + } else { + parentNode.addChild(currentNode); + linked = true; + } + currentPath = parentPath; + currentNode = parentNode; } - parentKey = buildKey(account, parentPath); - parentNode = mMap.get(parentKey); - if (parentNode == null) { - parentNode = new Node(parentKey, null); - parentNode.addChild(currentNode); - mMap.put(parentKey, parentNode); - } else { - parentNode.addChild(currentNode); - linked = true; + + String linkedTo = OCFile.ROOT_PATH; + if (linked) { + linkedTo = parentNode.getKey().substring(account.name.length()); } - currentPath = parentPath; - currentNode = parentNode; - } - String linkedTo = OCFile.ROOT_PATH; - if (linked) { - linkedTo = parentNode.getKey().substring(account.name.length()); + return new Pair(targetKey, linkedTo); } - return new Pair(targetKey, linkedTo); }; diff --git a/src/com/owncloud/android/operations/CreateShareViaLinkOperation.java b/src/com/owncloud/android/operations/CreateShareViaLinkOperation.java index e9cb7d2d..bed23c70 100644 --- a/src/com/owncloud/android/operations/CreateShareViaLinkOperation.java +++ b/src/com/owncloud/android/operations/CreateShareViaLinkOperation.java @@ -41,8 +41,6 @@ import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.operations.common.SyncOperation; -import java.util.ArrayList; - public class CreateShareViaLinkOperation extends SyncOperation { private String mPath; @@ -76,19 +74,19 @@ public class CreateShareViaLinkOperation extends SyncOperation { RemoteOperation operation = new GetRemoteSharesForFileOperation(mPath, false, false); RemoteOperationResult result = operation.execute(client); - boolean shareByLink = false; - // Check if the file is shared by link - if (result.isSuccess() && result.getData().size() > 0){ - ArrayList shares = result.getData(); - for(Object object: shares){ - if (((OCShare) object).getShareType() == ShareType.PUBLIC_LINK){ - shareByLink = true; + // Create public link if doesn't exist yet + boolean publicShareExists = false; + if (result.isSuccess()) { + OCShare share = null; + for (int i=0 ; i