From dae3510923791597ce34ffcec687650211a3fa58 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 5 Feb 2020 19:25:26 +0100 Subject: [PATCH] feat(Filesystem): Remove createIntermediateDirectories from MkdirOptions (#2410) --- .../src/main/java/com/getcapacitor/plugin/Filesystem.java | 6 +----- core/src/core-plugin-definitions.ts | 6 ------ core/src/web/filesystem.ts | 7 +------ electron/src/electron/filesystem.ts | 5 +---- ios/Capacitor/Capacitor/Plugins/Filesystem.swift | 6 +----- 5 files changed, 4 insertions(+), 26 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java index 7f7fdee03e..90d12b0c2d 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java @@ -326,10 +326,6 @@ public void mkdir(PluginCall call) { saveCall(call); String path = call.getString("path"); String directory = getDirectoryParameter(call); - boolean intermediate = call.getBoolean("createIntermediateDirectories", false).booleanValue(); - if (call.getBoolean("createIntermediateDirectories") != null) { - Log.w(getLogTag(),"createIntermediateDirectories is deprecated, use recursive"); - } boolean recursive = call.getBoolean("recursive", false).booleanValue(); File fileObject = getFileObject(path, directory); @@ -342,7 +338,7 @@ public void mkdir(PluginCall call) { if (!isPublicDirectory(directory) || isStoragePermissionGranted(PluginRequestCodes.FILESYSTEM_REQUEST_WRITE_FOLDER_PERMISSIONS, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { boolean created = false; - if (intermediate || recursive) { + if (recursive) { created = fileObject.mkdirs(); } else { created = fileObject.mkdir(); diff --git a/core/src/core-plugin-definitions.ts b/core/src/core-plugin-definitions.ts index 409627b674..547b973a2d 100644 --- a/core/src/core-plugin-definitions.ts +++ b/core/src/core-plugin-definitions.ts @@ -663,12 +663,6 @@ export interface MkdirOptions { * The FilesystemDirectory to make the new directory in */ directory?: FilesystemDirectory; - /** - * @deprecated - use recursive - * Whether to create any missing parent directories as well - * Defaults to false - */ - createIntermediateDirectories?: boolean; /** * Whether to create any missing parent directories as well. * Defaults to false diff --git a/core/src/web/filesystem.ts b/core/src/web/filesystem.ts index 8b0ff566e5..0e2232cf01 100644 --- a/core/src/web/filesystem.ts +++ b/core/src/web/filesystem.ts @@ -246,12 +246,7 @@ export class FilesystemPluginWeb extends WebPlugin implements FilesystemPlugin { */ async mkdir(options: MkdirOptions): Promise { const path: string = this.getPath(options.directory, options.path); - const createIntermediateDirectories = options.createIntermediateDirectories; - if (options.createIntermediateDirectories !== undefined) { - console.warn('createIntermediateDirectories is deprecated, use recursive'); - } - const recursive = options.recursive; - const doRecursive = (createIntermediateDirectories || recursive); + const doRecursive = options.recursive; const parentPath = path.substr(0, path.lastIndexOf('/')); let depth = (path.match(/\//g) || []).length; diff --git a/electron/src/electron/filesystem.ts b/electron/src/electron/filesystem.ts index 43e7fd8a61..5cfff5e6d9 100644 --- a/electron/src/electron/filesystem.ts +++ b/electron/src/electron/filesystem.ts @@ -113,10 +113,7 @@ export class FilesystemPluginElectron extends WebPlugin implements FilesystemPlu if(Object.keys(this.fileLocations).indexOf(options.directory) === -1) reject(`${options.directory} is currently not supported in the Electron implementation.`); let lookupPath = this.fileLocations[options.directory] + options.path; - if (options.createIntermediateDirectories !== undefined) { - console.warn('createIntermediateDirectories is deprecated, use recursive'); - } - const doRecursive = options.createIntermediateDirectories || options.recursive; + const doRecursive = options.recursive; this.NodeFS.mkdir(lookupPath, { recursive: doRecursive }, (err:any) => { if(err) { reject(err); diff --git a/ios/Capacitor/Capacitor/Plugins/Filesystem.swift b/ios/Capacitor/Capacitor/Plugins/Filesystem.swift index 9c8046fb52..889c1e9ae2 100644 --- a/ios/Capacitor/Capacitor/Plugins/Filesystem.swift +++ b/ios/Capacitor/Capacitor/Plugins/Filesystem.swift @@ -222,10 +222,6 @@ public class CAPFilesystemPlugin : CAPPlugin { return } - let createIntermediateDirectories = call.get("createIntermediateDirectories", Bool.self, false)! - if let _ = call.get("createIntermediateDirectories", Bool.self) { - CAPLog.print("createIntermediateDirectories is deprecated, use recursive") - } let recursive = call.get("recursive", Bool.self, false)! let directoryOption = call.get("directory", String.self, DEFAULT_DIRECTORY)! guard let fileUrl = getFileUrl(path, directoryOption) else { @@ -234,7 +230,7 @@ public class CAPFilesystemPlugin : CAPPlugin { } do { - try FileManager.default.createDirectory(at: fileUrl, withIntermediateDirectories: createIntermediateDirectories || recursive, attributes: nil) + try FileManager.default.createDirectory(at: fileUrl, withIntermediateDirectories: recursive, attributes: nil) call.success() } catch let error as NSError { handleError(call, error.localizedDescription, error)