Fix: compileSdk를 34로 낮추고 FTPFileSystem final 필드 버그 수정
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user