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