Skip to content

Commit

Permalink
Fix bug with overwriting on inflation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Aiezza authored and Alex Aiezza committed Apr 28, 2016
1 parent c3c5157 commit 290e5d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/edu/rit/flick/AbstractFlickFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import org.apache.commons.io.FileUtils;

import com.google.common.io.Files;

import edu.rit.flick.config.Configuration;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
Expand Down Expand Up @@ -56,8 +58,14 @@ public AbstractFlickFile( final Configuration configuration )
final Object outputPath = configuration.getOption( OUTPUT_PATH );

fileIn = new File( inputPath );
fileOut = new File( outputPath == null ? fileIn.getPath() + getDefaultDeflatedExtension()
: (String) outputPath );
fileOut = new File(
outputPath == null ? configuration
.getFlag( ARCHIVE_MODE )
? fileIn.getPath() + getDefaultDeflatedExtension()
: fileIn.getPath()
.replaceAll( "." + Files.getFileExtension(
fileIn.getPath() ), "" )
: (String) outputPath );

if ( !fileIn.exists() )
throw new NoSuchFileException( fileIn.getPath(), null,
Expand Down
4 changes: 2 additions & 2 deletions src/edu/rit/flick/DefaultFlickFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ public String getDefaultDeflatedExtension()
{
for ( final FileInflator fi : fileInflators )
if ( fi.getExtensions().contains( fileExt ) )
return Files.getFileExtension( fileIn.getPath().substring( 0,
fileIn.getPath().indexOf( fi.getDefaultDeflatedExtension() ) ) );
return Files.getFileExtension(
fileIn.getPath().replaceAll( fi.getDefaultDeflatedExtension(), "" ) );
}

return DEFAULT_DEFLATED_EXTENSION;
Expand Down

0 comments on commit 290e5d9

Please sign in to comment.