From 5852944ee7faec7ed93f95b83ccc90e50ccc4377 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sat, 5 Aug 2023 06:02:55 +0300 Subject: [PATCH] fixed #6956: Update Dropbox direct link format --- ShareX.UploadersLib/FileUploaders/Dropbox.cs | 21 ++------------ ShareX.UploadersLib/UploadersConfig.cs | 3 -- ShareX/SettingManager.cs | 30 -------------------- 3 files changed, 3 insertions(+), 51 deletions(-) diff --git a/ShareX.UploadersLib/FileUploaders/Dropbox.cs b/ShareX.UploadersLib/FileUploaders/Dropbox.cs index 8adcc8b06..f3977475c 100644 --- a/ShareX.UploadersLib/FileUploaders/Dropbox.cs +++ b/ShareX.UploadersLib/FileUploaders/Dropbox.cs @@ -59,14 +59,6 @@ public override GenericUploader CreateUploader(UploadersConfig config, TaskRefer public override TabPage GetUploadersConfigTabPage(UploadersConfigForm form) => form.tpDropbox; } - // TEMP: For backward compatibility - public enum DropboxURLType - { - Default, - Shortened, - Direct - } - public sealed class Dropbox : FileUploader, IOAuth2Basic { private const string APIVersion = "2"; @@ -91,8 +83,7 @@ public sealed class Dropbox : FileUploader, IOAuth2Basic private const string URLDelete = URLAPI + "/files/delete"; private const string URLMove = URLAPI + "/files/move"; - private const string URLShareDirect = "https://dl.dropboxusercontent.com/s"; - private const string URLPublicDirect = "https://dl.dropboxusercontent.com/u"; + private const string URLShareDirect = "https://dl.dropboxusercontent.com/scl/fi/"; public OAuth2Info AuthInfo { get; set; } public string UploadPath { get; set; } @@ -444,18 +435,12 @@ public DropboxMetadata Move(string fromPath, string toPath) private static string GetDirectShareableURL(string url) { - string find = "dropbox.com/s/"; + string find = "dropbox.com/scl/fi/"; int index = url.IndexOf(find); if (index > -1) { - string path = url.Substring(index + find.Length); - index = path.LastIndexOf('?'); - - if (index > -1) - { - path = path.Remove(index); - } + string path = url.Remove(0, index + find.Length); if (!string.IsNullOrEmpty(path)) { diff --git a/ShareX.UploadersLib/UploadersConfig.cs b/ShareX.UploadersLib/UploadersConfig.cs index f93c3ba00..9cea938e0 100644 --- a/ShareX.UploadersLib/UploadersConfig.cs +++ b/ShareX.UploadersLib/UploadersConfig.cs @@ -160,9 +160,6 @@ public class UploadersConfig : SettingsBase public bool DropboxAutoCreateShareableLink { get; set; } = true; public bool DropboxUseDirectLink { get; set; } = false; - // TEMP: For backward compatibility - public DropboxURLType DropboxURLType = DropboxURLType.Default; - #endregion Dropbox #region FTP diff --git a/ShareX/SettingManager.cs b/ShareX/SettingManager.cs index 4dc70b4ce..39ec11e9f 100644 --- a/ShareX/SettingManager.cs +++ b/ShareX/SettingManager.cs @@ -28,7 +28,6 @@ You should have received a copy of the GNU General Public License using ShareX.Properties; using ShareX.ScreenCaptureLib; using ShareX.UploadersLib; -using ShareX.UploadersLib.FileUploaders; using System; using System.Collections.Generic; using System.IO; @@ -272,35 +271,6 @@ private static void MigrateHistoryFile() private static void UploadersConfigBackwardCompatibilityTasks() { - if (UploadersConfig.IsUpgradeFrom("11.6.0")) - { - if (UploadersConfig.DropboxURLType == DropboxURLType.Direct) - { - UploadersConfig.DropboxUseDirectLink = true; - } - - if (!string.IsNullOrEmpty(UploadersConfig.AmazonS3Settings.Endpoint)) - { - bool endpointFound = false; - - foreach (AmazonS3Endpoint endpoint in AmazonS3.Endpoints) - { - if (endpoint.Region != null && endpoint.Region.Equals(UploadersConfig.AmazonS3Settings.Endpoint, StringComparison.OrdinalIgnoreCase)) - { - UploadersConfig.AmazonS3Settings.Endpoint = endpoint.Endpoint; - UploadersConfig.AmazonS3Settings.Region = endpoint.Region; - endpointFound = true; - break; - } - } - - if (!endpointFound) - { - UploadersConfig.AmazonS3Settings.Endpoint = ""; - } - } - } - if (UploadersConfig.CustomUploadersList != null) { foreach (CustomUploaderItem cui in UploadersConfig.CustomUploadersList)