mirror of
https://github.com/java-decompiler/jd-gui.git
synced 2024-11-23 12:39:52 +00:00
Fixes #1, Save All Sources does not work, zip file is not created
This commit is contained in:
parent
0934ee13a5
commit
19a6ca8054
3
.gitignore
vendored
3
.gitignore
vendored
@ -27,3 +27,6 @@ target/
|
||||
# Gradle
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# WinMerge
|
||||
*.bak
|
||||
|
@ -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)
|
||||
|
||||
@ -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()
|
||||
|
@ -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
|
||||
|
||||
@ -73,4 +75,9 @@ class SaveAllSourcesView {
|
||||
saveAllSourcesDialog.visible = false
|
||||
}
|
||||
}
|
||||
|
||||
void showActionFailedDialog() {
|
||||
JOptionPane.showMessageDialog(
|
||||
swing.saveAllSourcesDialog, '"Save All Sources" action failed.', 'Error', JOptionPane.ERROR_MESSAGE)
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user