Skip to content

Commit

Permalink
add subfolder to avoid collisions on naming and permissions (fixes #582
Browse files Browse the repository at this point in the history
…, #549)
  • Loading branch information
benfry committed Nov 24, 2022
1 parent 3566377 commit c1f2434
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,17 @@ static private void createAndShowGUI(String[] args) {

// Create a location for untitled sketches
try {
//untitledFolder = Util.createTempFolder("untitled", "sketches", null);
//untitledFolder.deleteOnExit();
untitledFolder = Util.getProcessingTemp();
// Users on a shared machine may also share a TEMP folder,
// which can cause naming collisions; use a UUID as the name
// for the subfolder to introduce another layer of indirection.
// https://github.com/processing/processing4/issues/549
// The UUID also prevents collisions when restarting the
// software. Otherwise, after using up the a-z naming options
// it was not possible for users to restart (without manually
// finding and deleting the TEMP files).
// https://github.com/processing/processing4/issues/582
String uuid = UUID.randomUUID().toString();
untitledFolder = new File(Util.getProcessingTemp(), uuid);

} catch (IOException e) {
Messages.showError("Trouble without a name",
Expand Down Expand Up @@ -437,9 +445,9 @@ static public void cleanTempFolders() {
if (expiredFiles != null) {
// Remove the files approved for deletion
for (File file : expiredFiles) {
//file.delete(); // not as safe
try {
Platform.deleteFile(file); // move to trash
// move to trash or delete if unavailable
Platform.deleteFile(file);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
3 changes: 3 additions & 0 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ _ this was on Linux; curious if Windows has an issue too?
_ overwrite with -Djava.io.tmpdir=/path/to/tmpdir
_ maybe we should use java.io.tmpdir -> processing -> $USER
_ https://github.com/processing/processing4/issues/549
_ put in a note about the cleaning process
_ too many temp folders prevent restart
_ https://github.com/processing/processing4/issues/582

_ "Show Sketch Folder" for libraries needs to treat the sketch as Untitled
_ and with that, switch to another directory
_ https://github.com/processing/processing4/issues/548

_ theme is not being kept after Processing restart on Windows?
_ https://github.com/processing/processing4/issues/565

Expand Down

0 comments on commit c1f2434

Please sign in to comment.