Skip to content

Conversation

@JonnyPower
Copy link
Member

  • same directory as input
  • same filename with results suffix

- same directory as input
- same filename with results suffix
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Filename Collision Resolution Fails

The resolveFileNameCollision method incorrectly determines the filename and extension for collision resolution. It uses originalFile.getAbsolutePath() to find the last dot, instead of originalFile.getName(). This causes incorrect parsing when directory names contain dots (e.g., /home/user.name/file.txt, /tmp/version1.2/myfile.txt) or when dealing with hidden files (e.g., /path/to/.bashrc). As a result, collision-resolved filenames are malformed (e.g., /home/user (1).name/file, /path/to/ (1).bashrc).

src/main/java/com/tractionrec/recrec/ui/RecRecResultsPreview.java#L669-L697

*/
private File resolveFileNameCollision(File originalFile) {
if (!originalFile.exists()) {
return originalFile;
}
String originalPath = originalFile.getAbsolutePath();
String nameWithoutExt;
String extension;
int dotIndex = originalPath.lastIndexOf('.');
if (dotIndex > 0) {
nameWithoutExt = originalPath.substring(0, dotIndex);
extension = originalPath.substring(dotIndex);
} else {
nameWithoutExt = originalPath;
extension = "";
}
int counter = 1;
File candidateFile;
do {
String newPath = nameWithoutExt + " (" + counter + ")" + extension;
candidateFile = new File(newPath);
counter++;
} while (candidateFile.exists());
return candidateFile;
}

Fix in Cursor


Bug: Export Filename Extension Handling Flaw

The getDefaultExportFileName() method incorrectly derives default export filenames from input files. It preserves the original file's extension (e.g., data.txt), leading to confusing double extensions like data - results.txt.csv after the export logic appends .csv. Additionally, the logic for identifying extensions (if (dotIndex > 0)) is flawed, causing unusual filenames for files ending with a dot (e.g., file. becomes file - results.), as it treats the trailing dot as an extension.

src/main/java/com/tractionrec/recrec/ui/RecRecResultsPreview.java#L606-L617

// For CSV-based queries, use original filename + " - results"
if (state.inputFile != null) {
String originalName = state.inputFile.getName();
int dotIndex = originalName.lastIndexOf('.');
if (dotIndex > 0) {
String nameWithoutExt = originalName.substring(0, dotIndex);
String extension = originalName.substring(dotIndex);
return nameWithoutExt + " - results" + extension;
} else {
return originalName + " - results.csv";
}
}

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants