removed debug logs
This commit is contained in:
parent
8a8a7a9416
commit
8f273407ac
@ -8,7 +8,6 @@ import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@ -39,40 +38,30 @@ final class DriveUtils {
|
||||
addDrive(drives, root);
|
||||
}
|
||||
}
|
||||
log("File.listRoots(): " + describeFiles(roots));
|
||||
|
||||
if (MainApp.CURRENT_OS == MainApp.OS.WINDOWS) {
|
||||
addWindowsFileSystemViewDrives(drives);
|
||||
addWindowsMappedNetworkDrives(drives);
|
||||
}
|
||||
|
||||
log("available drives: " + describeFiles(drives));
|
||||
return new ArrayList<>(drives);
|
||||
}
|
||||
|
||||
static File resolveDriveForLoading(File drive) {
|
||||
log("resolveDriveForLoading input: " + describeFile(drive));
|
||||
if (drive == null || MainApp.CURRENT_OS != MainApp.OS.WINDOWS || drive.isDirectory()) {
|
||||
log("resolveDriveForLoading direct: " + describeFile(drive));
|
||||
return drive;
|
||||
}
|
||||
|
||||
File normalizedDrive = normalizeDriveKey(drive);
|
||||
Map<File, File> mappedDrives = getWindowsMappedNetworkDriveTargets();
|
||||
log("net use mappings: " + describeMappings(mappedDrives));
|
||||
File mappedTarget = mappedDrives.get(normalizedDrive);
|
||||
log("resolved mapped target for " + describeFile(normalizedDrive) + ": " + describeFile(mappedTarget));
|
||||
|
||||
if (mappedDrives.containsKey(normalizedDrive) && reconnectWindowsMappedDrive(normalizedDrive)) {
|
||||
log("resolveDriveForLoading reconnected drive accepted: " + describeFile(normalizedDrive));
|
||||
return normalizedDrive;
|
||||
}
|
||||
|
||||
if (mappedTarget != null && mappedTarget.isDirectory()) {
|
||||
log("resolveDriveForLoading mapped target accepted: " + describeFile(mappedTarget));
|
||||
return mappedTarget;
|
||||
}
|
||||
log("resolveDriveForLoading fallback to selected drive: " + describeFile(drive));
|
||||
return drive;
|
||||
}
|
||||
|
||||
@ -94,7 +83,6 @@ final class DriveUtils {
|
||||
File root = rootPath.toFile();
|
||||
return getWindowsMappedNetworkDriveTargets().containsKey(normalizeDriveKey(root));
|
||||
} catch (Exception ex) {
|
||||
log("mapped path check failed for " + describeFile(directory) + ": " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -112,7 +100,6 @@ final class DriveUtils {
|
||||
}
|
||||
files.add(new File(directory, name));
|
||||
}
|
||||
log("cmd dir entries for " + describeFile(directory) + ": " + describeFiles(files));
|
||||
return files.toArray(new File[0]);
|
||||
}
|
||||
|
||||
@ -169,7 +156,6 @@ final class DriveUtils {
|
||||
new InputStreamReader(process.getInputStream(), Charset.defaultCharset()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
log("net use line: " + line);
|
||||
Matcher mappingMatcher = WINDOWS_NET_USE_MAPPING_PATTERN.matcher(line);
|
||||
if (mappingMatcher.find()) {
|
||||
mappedDrives.put(
|
||||
@ -186,13 +172,8 @@ final class DriveUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (process.waitFor(2, TimeUnit.SECONDS)) {
|
||||
log("net use exit code: " + process.exitValue());
|
||||
} else {
|
||||
log("net use did not finish within timeout");
|
||||
}
|
||||
process.waitFor(2, TimeUnit.SECONDS);
|
||||
} catch (Exception ignore) {
|
||||
log("net use failed: " + ignore.getMessage());
|
||||
} finally {
|
||||
if (process != null && process.isAlive()) {
|
||||
process.destroyForcibly();
|
||||
@ -207,13 +188,11 @@ final class DriveUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
log("attempting mapped drive reconnect via dir: " + describeFile(normalizedDrive));
|
||||
int exitCode = runWindowsProbeCommand("cmd.exe", "/c", "dir", normalizedDrive.getPath());
|
||||
log("mapped drive reconnect dir exit code: " + exitCode + ", after: " + describeFile(normalizedDrive));
|
||||
runWindowsProbeCommand("cmd.exe", "/c", "dir", normalizedDrive.getPath());
|
||||
return normalizedDrive.isDirectory();
|
||||
}
|
||||
|
||||
private static int runWindowsProbeCommand(String... command) {
|
||||
private static void runWindowsProbeCommand(String... command) {
|
||||
Process process = null;
|
||||
try {
|
||||
process = new ProcessBuilder(command)
|
||||
@ -221,23 +200,16 @@ final class DriveUtils {
|
||||
.start();
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream(), Charset.defaultCharset()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
log("probe line: " + line);
|
||||
while (reader.readLine() != null) {
|
||||
}
|
||||
}
|
||||
if (process.waitFor(5, TimeUnit.SECONDS)) {
|
||||
return process.exitValue();
|
||||
}
|
||||
log("probe did not finish within timeout");
|
||||
process.waitFor(5, TimeUnit.SECONDS);
|
||||
} catch (Exception ex) {
|
||||
log("probe failed: " + ex.getMessage());
|
||||
} finally {
|
||||
if (process != null && process.isAlive()) {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static List<String> runWindowsDirectoryListCommand(File directory) {
|
||||
@ -251,22 +223,18 @@ final class DriveUtils {
|
||||
new InputStreamReader(process.getInputStream(), Charset.defaultCharset()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
log("dir list line: " + line);
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
if (process.waitFor(5, TimeUnit.SECONDS)) {
|
||||
int exitCode = process.exitValue();
|
||||
log("dir list exit code: " + exitCode);
|
||||
if (exitCode != 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
} else {
|
||||
log("dir list did not finish within timeout");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log("dir list failed: " + ex.getMessage());
|
||||
return new ArrayList<>();
|
||||
} finally {
|
||||
if (process != null && process.isAlive()) {
|
||||
@ -293,57 +261,4 @@ final class DriveUtils {
|
||||
}
|
||||
drives.add(normalizeDriveKey(drive));
|
||||
}
|
||||
|
||||
private static void log(String message) {
|
||||
System.err.println("[DRIVE] " + message);
|
||||
}
|
||||
|
||||
private static String describeFile(File file) {
|
||||
if (file == null) {
|
||||
return "<null>";
|
||||
}
|
||||
try {
|
||||
return file.getPath()
|
||||
+ " [abs=" + file.getAbsolutePath()
|
||||
+ ", exists=" + file.exists()
|
||||
+ ", dir=" + file.isDirectory()
|
||||
+ ", canRead=" + file.canRead()
|
||||
+ "]";
|
||||
} catch (Exception ex) {
|
||||
return file.getPath() + " [describe failed: " + ex.getMessage() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private static String describeFiles(File[] files) {
|
||||
if (files == null) {
|
||||
return "<null>";
|
||||
}
|
||||
return describeFiles(Arrays.asList(files));
|
||||
}
|
||||
|
||||
private static String describeFiles(Iterable<File> files) {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
boolean first = true;
|
||||
for (File file : files) {
|
||||
if (!first) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(describeFile(file));
|
||||
first = false;
|
||||
}
|
||||
return sb.append(']').toString();
|
||||
}
|
||||
|
||||
private static String describeMappings(Map<File, File> mappings) {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
boolean first = true;
|
||||
for (Map.Entry<File, File> entry : mappings.entrySet()) {
|
||||
if (!first) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(describeFile(entry.getKey())).append(" -> ").append(describeFile(entry.getValue()));
|
||||
first = false;
|
||||
}
|
||||
return sb.append(']').toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,28 +125,20 @@ public class FilePanel extends JPanel {
|
||||
|
||||
Object selObj = driveCombo.getSelectedItem();
|
||||
if (selObj instanceof File sel) {
|
||||
System.err.println("[DRIVE] combo selected: " + describeDriveForLog(sel));
|
||||
FilePanelTab currentTab = getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
File targetDirectory = DriveUtils.resolveDriveForLoading(sel);
|
||||
System.err.println("[DRIVE] target after drive resolver: " + describeDriveForLog(targetDirectory));
|
||||
if (driveSelectionTargetResolver != null) {
|
||||
try {
|
||||
File resolved = driveSelectionTargetResolver.apply(targetDirectory);
|
||||
System.err.println("[DRIVE] opposite-panel resolver returned: " + describeDriveForLog(resolved));
|
||||
if (resolved != null && resolved.exists() && resolved.isDirectory() && isWithinSelectedDrive(resolved, targetDirectory)) {
|
||||
targetDirectory = resolved;
|
||||
System.err.println("[DRIVE] opposite-panel resolver accepted: " + describeDriveForLog(targetDirectory));
|
||||
} else {
|
||||
System.err.println("[DRIVE] opposite-panel resolver rejected for selected drive: " + describeDriveForLog(targetDirectory));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println("[DRIVE] opposite-panel resolver failed: " + ex.getMessage());
|
||||
} catch (Exception ignore) {
|
||||
// fall back to selected drive root
|
||||
}
|
||||
}
|
||||
|
||||
System.err.println("[DRIVE] loading selected drive target: " + describeDriveForLog(targetDirectory));
|
||||
currentTab.loadDirectory(targetDirectory);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try { currentTab.getFileTable().requestFocusInWindow(); } catch (Exception ignore) {}
|
||||
@ -277,22 +269,6 @@ public class FilePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private static String describeDriveForLog(File file) {
|
||||
if (file == null) {
|
||||
return "<null>";
|
||||
}
|
||||
try {
|
||||
return file.getPath()
|
||||
+ " [abs=" + file.getAbsolutePath()
|
||||
+ ", exists=" + file.exists()
|
||||
+ ", dir=" + file.isDirectory()
|
||||
+ ", canRead=" + file.canRead()
|
||||
+ "]";
|
||||
} catch (Exception ex) {
|
||||
return file.getPath() + " [describe failed: " + ex.getMessage() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWithinSelectedDrive(File directory, File selectedDrive) {
|
||||
try {
|
||||
java.nio.file.Path dirPath = directory.toPath().toAbsolutePath().normalize();
|
||||
|
||||
@ -1473,34 +1473,24 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
|
||||
public void loadDirectory(File directory, List<FileItem> preloadedItems, boolean autoSelectFirst, boolean requestFocus, final Runnable postLoadAction) {
|
||||
File requestedDirectory = directory;
|
||||
System.err.println("[DRIVE] FilePanelTab.loadDirectory requested: " + describeDirectoryForLog(requestedDirectory));
|
||||
|
||||
// Ensure we load an existing directory - try parents if necessary
|
||||
File dirToLoad = directory;
|
||||
while (dirToLoad != null && !dirToLoad.isDirectory()) {
|
||||
System.err.println("[DRIVE] loadDirectory candidate is not directory, trying parent: " + describeDirectoryForLog(dirToLoad));
|
||||
dirToLoad = dirToLoad.getParentFile();
|
||||
}
|
||||
|
||||
if (dirToLoad == null) {
|
||||
dirToLoad = new File(System.getProperty("user.home"));
|
||||
System.err.println("[DRIVE] loadDirectory fell back to user.home: " + describeDirectoryForLog(dirToLoad));
|
||||
if (!dirToLoad.isDirectory()) {
|
||||
dirToLoad = new File(File.separator);
|
||||
System.err.println("[DRIVE] loadDirectory fell back to File.separator: " + describeDirectoryForLog(dirToLoad));
|
||||
}
|
||||
}
|
||||
directory = dirToLoad;
|
||||
if (requestedDirectory != directory) {
|
||||
System.err.println("[DRIVE] loadDirectory final candidate: " + describeDirectoryForLog(directory));
|
||||
}
|
||||
|
||||
// If we are switching directories, cleanup any previously extracted archive temp dirs
|
||||
cleanupArchiveTempDirIfNeeded(directory);
|
||||
|
||||
if (directory == null || !directory.isDirectory()) {
|
||||
System.err.println("[DRIVE] loadDirectory aborted, final candidate is invalid: " + describeDirectoryForLog(directory));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1859,12 +1849,7 @@ public class FilePanelTab extends JPanel {
|
||||
File[] files = directory.listFiles();
|
||||
if (MainApp.CURRENT_OS == MainApp.OS.WINDOWS && DriveUtils.isWindowsMappedOrUncPath(directory)) {
|
||||
File[] cmdFiles = DriveUtils.listWindowsDirectoryWithCmd(directory);
|
||||
System.err.println("[DRIVE] listFiles count=" + (files != null ? files.length : -1)
|
||||
+ ", cmd dir count=" + cmdFiles.length
|
||||
+ " for " + describeDirectoryForLog(directory));
|
||||
files = mergeFileArrays(files, cmdFiles);
|
||||
System.err.println("[DRIVE] merged directory entry count=" + (files != null ? files.length : -1)
|
||||
+ " for " + describeDirectoryForLog(directory));
|
||||
}
|
||||
List<FileItem> items = new ArrayList<>();
|
||||
File parent = directory.getParentFile();
|
||||
@ -4461,22 +4446,6 @@ public class FilePanelTab extends JPanel {
|
||||
public File getCurrentDirectory() {
|
||||
return currentDirectory;
|
||||
}
|
||||
|
||||
private static String describeDirectoryForLog(File file) {
|
||||
if (file == null) {
|
||||
return "<null>";
|
||||
}
|
||||
try {
|
||||
return file.getPath()
|
||||
+ " [abs=" + file.getAbsolutePath()
|
||||
+ ", exists=" + file.exists()
|
||||
+ ", dir=" + file.isDirectory()
|
||||
+ ", canRead=" + file.canRead()
|
||||
+ "]";
|
||||
} catch (Exception ex) {
|
||||
return file.getPath() + " [describe failed: " + ex.getMessage() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
// FileTableModel
|
||||
private class FileTableModel extends AbstractTableModel {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user