Skip to content

Commit f4cd2c7

Browse files
WElRDWElRD
authored andcommitted
Fixed a bug with renaming imported projects, when a project with the
same name already exists
1 parent 9a10057 commit f4cd2c7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Card Creator/src/main/java/vv3ird/populatecard/control/ProjectManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,16 @@ public static Path importZipProject(Path sourceFile) {
439439
Project p = Project.load(projectFile);
440440
targetRoot = Paths.get("projects", p.getName());
441441
int i = 0;
442+
boolean renamedProject = false;
442443
while (Files.exists(targetRoot)) {
443444
targetRoot = Paths.get("projects", p.getName() + "_" + ++i);
445+
renamedProject = true;
444446
}
445447
System.out.println("Source Root: " + sourceRoot);
446448
System.out.println("Target Root: " + targetRoot);
447449
Files.createDirectories(targetRoot);
448450
Files.walkFileTree(sourceRoot, new CopyFileVisitor(targetRoot));
449-
targetProject = Paths.get("projects", p.getName() + "_" + i, projectFile.getFileName().toString());
451+
targetProject = Paths.get("projects", p.getName() + (renamedProject ? "_" + i : ""), projectFile.getFileName().toString());
450452
}
451453
return targetProject;
452454
}

0 commit comments

Comments
 (0)