@@ -330,11 +330,11 @@ protected void extractFile( final File srcF, final File dir, final InputStream c
330
330
}
331
331
332
332
// Hmm. Symlinks re-evaluate back to the original file here. Unsure if this is a good thing...
333
- final File f = FileUtils .resolveFile ( dir , entryName );
333
+ final File targetFileName = FileUtils .resolveFile ( dir , entryName );
334
334
335
335
// Make sure that the resolved path of the extracted file doesn't escape the destination directory
336
336
String canonicalDirPath = dir .getCanonicalPath ();
337
- String canonicalDestPath = f .getCanonicalPath ();
337
+ String canonicalDestPath = targetFileName .getCanonicalPath ();
338
338
339
339
if ( !canonicalDestPath .startsWith ( canonicalDirPath ) )
340
340
{
@@ -343,25 +343,25 @@ protected void extractFile( final File srcF, final File dir, final InputStream c
343
343
344
344
try
345
345
{
346
- if ( !shouldExtractEntry ( f , entryName , entryDate ) )
346
+ if ( !shouldExtractEntry ( targetFileName , entryName , entryDate ) )
347
347
{
348
348
return ;
349
349
}
350
350
351
351
// create intermediary directories - sometimes zip don't add them
352
- final File dirF = f .getParentFile ();
352
+ final File dirF = targetFileName .getParentFile ();
353
353
if ( dirF != null )
354
354
{
355
355
dirF .mkdirs ();
356
356
}
357
357
358
358
if ( !StringUtils .isEmpty ( symlinkDestination ) )
359
359
{
360
- SymlinkUtils .createSymbolicLink ( f , new File ( symlinkDestination ) );
360
+ SymlinkUtils .createSymbolicLink ( targetFileName , new File ( symlinkDestination ) );
361
361
}
362
362
else if ( isDirectory )
363
363
{
364
- f .mkdirs ();
364
+ targetFileName .mkdirs ();
365
365
}
366
366
else
367
367
{
@@ -371,37 +371,37 @@ else if ( isDirectory )
371
371
}
372
372
}
373
373
374
- f .setLastModified ( entryDate .getTime () );
374
+ targetFileName .setLastModified ( entryDate .getTime () );
375
375
376
376
if ( !isIgnorePermissions () && mode != null && !isDirectory )
377
377
{
378
- ArchiveEntryUtils .chmod ( f , mode );
378
+ ArchiveEntryUtils .chmod ( targetFileName , mode );
379
379
}
380
380
}
381
381
catch ( final FileNotFoundException ex )
382
382
{
383
- getLogger ().warn ( "Unable to expand to file " + f .getPath () );
383
+ getLogger ().warn ( "Unable to expand to file " + targetFileName .getPath () );
384
384
}
385
385
}
386
386
387
387
// Visible for testing
388
- protected boolean shouldExtractEntry ( File file , String entryName , Date entryDate ) throws IOException
388
+ protected boolean shouldExtractEntry ( File targetFileName , String entryName , Date entryDate ) throws IOException
389
389
{
390
390
// entryname | entrydate | filename | filedate | behavior
391
391
// (1) readme.txt | 1970 | readme.txt | 2020 | never overwrite
392
392
// (2) readme.txt | 2020 | readme.txt | 1970 | only overwrite when isOverWrite()
393
393
// (3) README.txt | 1970 | readme.txt | 2020 | warn + never overwrite
394
394
// (4) README.txt | 2020 | readme.txt | 1970 | warn + only overwrite when isOverWrite()
395
395
396
- String canonicalDestPath = file .getCanonicalPath ();
397
- boolean fileOnDiskIsNewerThanEntry = ( file .lastModified () >= entryDate .getTime () );
396
+ String canonicalDestPath = targetFileName .getCanonicalPath ();
397
+ boolean fileOnDiskIsNewerThanEntry = targetFileName .lastModified () >= entryDate .getTime ();
398
398
boolean differentCasing = !StringUtils .equalsIgnoreCase ( entryName , canonicalDestPath );
399
399
400
400
String casingMessage = String .format ( "Archive entry '%s' and existing file '%s' names differ only by case."
401
401
+ " This may cause issues on case-insensitive filesystems." , entryName , canonicalDestPath );
402
402
403
403
// Optimise for situation where we need no checks
404
- if ( !file .exists () )
404
+ if ( !targetFileName .exists () )
405
405
{
406
406
return true ;
407
407
}
0 commit comments