From 61761ebdd48946aab8d184e2a18cb6cac42c90dc Mon Sep 17 00:00:00 2001 From: maxiaoping <634115572@qq.com> Date: Mon, 11 Jul 2022 09:59:29 +0800 Subject: [PATCH] modify the logic of obtaining a share link (#937) --- app/build.gradle | 4 ++-- .../ui/dialog/GetShareLinkDialog.java | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 32a78ab2b..95591c497 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId 'com.seafile.seadroid2' minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 120 - versionName "2.2.45" + versionCode 121 + versionName "2.2.46" multiDexEnabled true resValue "string", "authorities", applicationId + '.cameraupload.provider' resValue "string", "account_type", "com.seafile.seadroid2.account.api2" diff --git a/app/src/main/java/com/seafile/seadroid2/ui/dialog/GetShareLinkDialog.java b/app/src/main/java/com/seafile/seadroid2/ui/dialog/GetShareLinkDialog.java index 49c03451f..d64053b1c 100644 --- a/app/src/main/java/com/seafile/seadroid2/ui/dialog/GetShareLinkDialog.java +++ b/app/src/main/java/com/seafile/seadroid2/ui/dialog/GetShareLinkDialog.java @@ -36,19 +36,19 @@ public GetShareLinkTask(String repoID, String path, boolean isdir, SeafConnectio @Override protected void runTask() { - - // If you has Shared links to delete Shared links DataManager dataManager = new DataManager(account); + //get share link ArrayList shareLinks = dataManager.getShareLink(repoID, path); - for (SeafLink shareLink : shareLinks) { - //delete link - dataManager.deleteShareLink(shareLink.getToken()); - } - //create new link - try { - link = conn.getShareLink(repoID, path, password, days); - } catch (SeafException e) { - setTaskException(e); + if (shareLinks.size() == 0) { + try { + //creating a Share link + link = conn.getShareLink(repoID, path, password, days); + } catch (SeafException e) { + setTaskException(e); + } + } else { + //return to existing link + link = shareLinks.get(0).getLink(); } }