File tree Expand file tree Collapse file tree 1 file changed +3
-16
lines changed
aspect-model-editor-service/src/main/java/org/eclipse/esmf/ame/services/utils Expand file tree Collapse file tree 1 file changed +3
-16
lines changed Original file line number Diff line number Diff line change @@ -94,28 +94,15 @@ public static void deleteFileSafely( @Nonnull final File file ) {
9494 return ;
9595 }
9696
97- waitForFileUnlock ( file , 10 , 200 );
98-
99- if ( !file .isDirectory () ) {
97+ if ( isFileLocked ( file ) ) {
98+ FileUtils . deleteQuietly ( file );
99+ } else if ( !file .isDirectory () ) {
100100 Files .deleteIfExists ( file .toPath () );
101101 } else {
102102 FileUtils .deleteDirectory ( file );
103103 }
104104 } catch ( final IOException e ) {
105105 throw new FileHandlingException ( "File could not be deleted: " + file .getAbsolutePath (), e );
106- } catch ( final InterruptedException e ) {
107- Thread .currentThread ().interrupt ();
108- throw new FileReadException ( "Interrupted while waiting to delete file: " + file .getAbsolutePath () );
109- }
110- }
111-
112- private static void waitForFileUnlock ( final File file , final int maxRetries , final long sleepMillis ) throws InterruptedException {
113- int retry = 0 ;
114- while ( isFileLocked ( file ) ) {
115- if ( retry ++ >= maxRetries ) {
116- throw new RuntimeException ( "File is still locked after retries: " + file .getAbsolutePath () );
117- }
118- Thread .sleep ( sleepMillis );
119106 }
120107 }
121108
You can’t perform that action at this time.
0 commit comments