Skip to content

Commit

Permalink
Fixes java-decompiler#1, Save All Sources does not work, zip file is …
Browse files Browse the repository at this point in the history
…not created
  • Loading branch information
emmanue1 committed Mar 26, 2015
1 parent 0934ee1 commit 19a6ca8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ target/
# Gradle
.gradle/
build/

# WinMerge
*.bak
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava
// Show
this.saveAllSourcesView.show(file)
// Execute background task
executor.submit(new Callable<Void>() {
Void call() throws Exception {
executor.execute(new Runnable() {
void run() {
int fileCount = savable.fileCount
int quotient = (fileCount / 100)

Expand All @@ -56,10 +56,15 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava
def path = Paths.get(file.toURI())
Files.deleteIfExists(path)

savable.save(api, this as SourcesSavable.Controller, this as SourcesSavable.Listener, path)
try {
savable.save(api, this as SourcesSavable.Controller, this as SourcesSavable.Listener, path)
} catch (Exception e) {
saveAllSourcesView.showActionFailedDialog()
cancel = true
}

if (cancel) {
Files.delete(path)
Files.deleteIfExists(path)
}

saveAllSourcesView.hide()
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/groovy/jd/gui/view/SaveAllSourcesView.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import groovy.swing.SwingBuilder
import jd.gui.api.API
import jd.gui.model.configuration.Configuration

import javax.swing.JDialog
import javax.swing.JOptionPane
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent

Expand Down Expand Up @@ -73,4 +75,9 @@ class SaveAllSourcesView {
saveAllSourcesDialog.visible = false
}
}

void showActionFailedDialog() {
JOptionPane.showMessageDialog(
swing.saveAllSourcesDialog, '"Save All Sources" action failed.', 'Error', JOptionPane.ERROR_MESSAGE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import jd.gui.spi.SourceSaver

import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
import java.util.regex.Pattern

class FileSourceSaverProvider implements SourceSaver {
Expand All @@ -28,7 +29,7 @@ class FileSourceSaverProvider implements SourceSaver {
listener.pathSaved(path)

entry.inputStream.withStream { InputStream is ->
Files.copy(is, path)
Files.copy(is, path, StandardCopyOption.REPLACE_EXISTING)
}
}
}

0 comments on commit 19a6ca8

Please sign in to comment.