From 710ec15fb12c09419d368d01f084bd0ca4d75ed0 Mon Sep 17 00:00:00 2001 From: Gyubin Han Date: Thu, 1 Jan 2026 04:11:31 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20compileSdk=EB=A5=BC=2034=EB=A1=9C=20?= =?UTF-8?q?=EB=82=AE=EC=B6=94=EA=B3=A0=20FTPFileSystem=20final=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Android Gradle Plugin 7.1.3과 호환 문제로 compileSdk 36 → 34로 변경 - targetSdk도 34로 변경 - FTPFileSystem에서 final 필드 rootDirectory에 두 번 할당하는 버그 수정 * getDefaultRootDirectory() 헬퍼 메서드로 로직 분리 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .idea/deviceManager.xml | 13 ++++++ app/build.gradle | 4 +- .../gyu/android/server/ftp/FTPFileSystem.java | 42 ++++++++++++++----- 3 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 .idea/deviceManager.xml diff --git a/.idea/deviceManager.xml b/.idea/deviceManager.xml new file mode 100644 index 0000000..91f9558 --- /dev/null +++ b/.idea/deviceManager.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 317bc7e..dbc8e99 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,12 +3,12 @@ plugins { } android { - compileSdk 36 + compileSdk 34 defaultConfig { applicationId "be.gyu.android.server.ftp" minSdk 21 - targetSdk 36 + targetSdk 34 versionCode 1 versionName "1.0" diff --git a/app/src/main/java/be/gyu/android/server/ftp/FTPFileSystem.java b/app/src/main/java/be/gyu/android/server/ftp/FTPFileSystem.java index 70f84f3..90aa352 100644 --- a/app/src/main/java/be/gyu/android/server/ftp/FTPFileSystem.java +++ b/app/src/main/java/be/gyu/android/server/ftp/FTPFileSystem.java @@ -17,25 +17,47 @@ public class FTPFileSystem { private File currentDirectory; public FTPFileSystem() { - // Use external storage public directory as root - // In production, you might want to use app-specific directory or allow user to choose - File externalStorage = Environment.getExternalStorageDirectory(); - this.rootDirectory = new File(externalStorage, "FTPServer"); + this(null); + } - // Create root directory if it doesn't exist - if (!rootDirectory.exists()) { - if (rootDirectory.mkdirs()) { - Log.i(TAG, "Root directory created: " + rootDirectory.getAbsolutePath()); + public FTPFileSystem(String rootDirectoryPath) { + if (rootDirectoryPath != null && !rootDirectoryPath.isEmpty()) { + // Use user-specified directory + File userDir = new File(rootDirectoryPath); + if (userDir.exists() && userDir.isDirectory()) { + this.rootDirectory = userDir; + Log.i(TAG, "Using user-specified root: " + rootDirectory.getAbsolutePath()); } else { - Log.w(TAG, "Failed to create root directory, using external storage root"); - this.rootDirectory = externalStorage; + Log.w(TAG, "User-specified directory does not exist: " + rootDirectoryPath); + this.rootDirectory = getDefaultRootDirectory(); } + } else { + // Use default directory + this.rootDirectory = getDefaultRootDirectory(); } this.currentDirectory = rootDirectory; Log.d(TAG, "File system initialized. Root: " + rootDirectory.getAbsolutePath()); } + private File getDefaultRootDirectory() { + File externalStorage = Environment.getExternalStorageDirectory(); + File ftpServerDir = new File(externalStorage, "FTPServer"); + + // Create root directory if it doesn't exist + if (!ftpServerDir.exists()) { + if (ftpServerDir.mkdirs()) { + Log.i(TAG, "Root directory created: " + ftpServerDir.getAbsolutePath()); + return ftpServerDir; + } else { + Log.w(TAG, "Failed to create root directory, using external storage root"); + return externalStorage; + } + } else { + return ftpServerDir; + } + } + public String getCurrentPath() { String relativePath = getRelativePath(currentDirectory); return relativePath.isEmpty() ? "/" : "/" + relativePath;