@@ -283,7 +283,7 @@ public FileInfo write(
283
283
} catch (AccessDeniedException ex ) {
284
284
String serviceUser = System .getProperty ("user.name" );
285
285
throw new IOException (
286
- "Couldn't create directories on file store. Are you sure that EQUELLA running as '"
286
+ "Couldn't create directories on file store. Are you sure that openEQUELLA running as '"
287
287
+ serviceUser
288
288
+ "' user has the correct permissions?" ,
289
289
ex );
@@ -426,29 +426,44 @@ public void commitFiles(TemporaryFileHandle staging, String folder, FileHandle d
426
426
File from = getFile (staging , folder );
427
427
File to = getFile (destination );
428
428
429
- LOGGER .info ("commitFiles: from " + from .getAbsolutePath ());
430
- LOGGER .info ("commitFiles: to " + to .getAbsolutePath ());
429
+ final String fromStr = from .getAbsolutePath ();
430
+ final String toStr = to .getAbsolutePath ();
431
+ LOGGER .info ("commitFiles: from [" + fromStr + "] to [" + toStr + "]" );
431
432
432
433
File trash = null ;
433
434
if (FileSystemHelper .exists (to )) {
434
- LOGGER .debug ("Destination exists renaming " );
435
+ LOGGER .debug ("Destination [" + to + "] exists. Moving to a staging 'trash' folder " );
435
436
trash = getFile (new TrashFile (staging ));
436
- LOGGER .debug ("Moving current to trash" );
437
+ LOGGER .debug ("Moving current [" + to + "] to trash [" + trash + "]" );
438
+
437
439
if (!FileSystemHelper .rename (to , trash , false )) {
438
440
FileSystemHelper .rename (trash , to , true );
439
- throw new FileSystemException ("Couldn't move to Trash ." );
441
+ throw new FileSystemException ("Couldn't move [" + to + "] to trash [" + trash + "] ." );
440
442
}
441
443
}
442
444
443
- LOGGER .debug ("About to rename staging to real item" );
445
+ LOGGER .debug ("About to rename staging [" + from + "] to real item [" + to + "]. " );
444
446
if (!FileSystemHelper .exists (from )) {
445
- LOGGER .debug ("no files to commit - making blank dir" );
447
+ LOGGER .debug ("no files to commit - making blank dir [" + to + "] " );
446
448
FileSystemHelper .mkdir (to );
447
449
} else {
448
- LOGGER .debug ("Renaming staging to real item" );
450
+ LOGGER .debug ("Renaming staging [" + from + "] to real item [" + to + "] " );
449
451
if (!FileSystemHelper .rename (from , to , false )) {
452
+ LOGGER .debug (
453
+ "The rename of staging ["
454
+ + from
455
+ + "] to real item ["
456
+ + to
457
+ + "] didn't work. Trying rename of trash to real item." );
450
458
if (trash != null ) {
451
- FileSystemHelper .rename (trash , to , true );
459
+ if (!FileSystemHelper .rename (trash , to , true )) {
460
+ LOGGER .debug (
461
+ "The rename of trash ["
462
+ + trash
463
+ + "] to real item ["
464
+ + to
465
+ + "] didn't work. Silently proceeding." );
466
+ }
452
467
}
453
468
throw new FileSystemException (
454
469
"Failed to commit to staging: "
@@ -459,10 +474,10 @@ public void commitFiles(TemporaryFileHandle staging, String folder, FileHandle d
459
474
}
460
475
461
476
if (trash != null ) {
462
- LOGGER .debug ("Deleting trash" );
477
+ LOGGER .debug ("Deleting trash [" + trash + "] " );
463
478
FileUtils .delete (trash .toPath (), null );
464
479
}
465
- LOGGER .debug ("Done" );
480
+ LOGGER .debug ("Done committing files from [" + staging + "] to [" + to + "] " );
466
481
}
467
482
468
483
@ Override
0 commit comments