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:
13
.idea/deviceManager.xml
generated
Normal file
13
.idea/deviceManager.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DeviceTable">
|
||||||
|
<option name="columnSorters">
|
||||||
|
<list>
|
||||||
|
<ColumnSorterState>
|
||||||
|
<option name="column" value="Name" />
|
||||||
|
<option name="order" value="ASCENDING" />
|
||||||
|
</ColumnSorterState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -3,12 +3,12 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 36
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "be.gyu.android.server.ftp"
|
applicationId "be.gyu.android.server.ftp"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 36
|
targetSdk 34
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
|
|||||||
@@ -17,25 +17,47 @@ public class FTPFileSystem {
|
|||||||
private File currentDirectory;
|
private File currentDirectory;
|
||||||
|
|
||||||
public FTPFileSystem() {
|
public FTPFileSystem() {
|
||||||
// Use external storage public directory as root
|
this(null);
|
||||||
// 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");
|
|
||||||
|
|
||||||
// Create root directory if it doesn't exist
|
|
||||||
if (!rootDirectory.exists()) {
|
|
||||||
if (rootDirectory.mkdirs()) {
|
|
||||||
Log.i(TAG, "Root directory created: " + rootDirectory.getAbsolutePath());
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "Failed to create root directory, using external storage root");
|
|
||||||
this.rootDirectory = externalStorage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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, "User-specified directory does not exist: " + rootDirectoryPath);
|
||||||
|
this.rootDirectory = getDefaultRootDirectory();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Use default directory
|
||||||
|
this.rootDirectory = getDefaultRootDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentDirectory = rootDirectory;
|
this.currentDirectory = rootDirectory;
|
||||||
Log.d(TAG, "File system initialized. Root: " + rootDirectory.getAbsolutePath());
|
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() {
|
public String getCurrentPath() {
|
||||||
String relativePath = getRelativePath(currentDirectory);
|
String relativePath = getRelativePath(currentDirectory);
|
||||||
return relativePath.isEmpty() ? "/" : "/" + relativePath;
|
return relativePath.isEmpty() ? "/" : "/" + relativePath;
|
||||||
|
|||||||
Reference in New Issue
Block a user