Skip to content

Commit

Permalink
improved locked file detection (windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
molok committed Apr 30, 2018
1 parent 761fe95 commit 9194f05
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>alebolo</groupId>
<artifactId>rabdomante</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<url>https://github.com/molok/rabdomante/</url>
<build>
<resources>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>alebolo</groupId>
<artifactId>rabdomante</artifactId>
<version>1.2.2-SNAPSHOT</version>
<version>1.2.2</version>
<url>https://github.com/molok/rabdomante/</url>

<dependencies>
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/alebolo/rabdomante/Msg.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ public static String solutionIncomplete() {
public static String grams() { return m.getString("grams"); }
public static String resultsheet_incomplete() { return m.getString("resultsheet_incomplete");}
public static String resultsheet_searchok() { return m.getString("resultsheet_searchok");}
public static String resultsheet_updated_at() { return m.getString("resultsheet_updated_at");
}

public static String resultsheet_updated_at() { return m.getString("resultsheet_updated_at"); }
public static String readLicense() { return m.getString("read_license"); }

public static String license() { return m.getString("license"); }
public static String fileLocked() { return m.getString("file_locked"); }
}
6 changes: 3 additions & 3 deletions src/main/java/alebolo/rabdomante/gui/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import static alebolo.rabdomante.xlsx.Utils.COLOR_USER_INPUT;

public class Gui extends Application {
public static final String WEBSITE = "https://github.com/molok/rabdomante/";
public static final String WEBSITE = "https://github.com/molok/rabdomante";
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final App app = new App();
private TextField selectedFileTxt;
Expand Down Expand Up @@ -319,7 +319,7 @@ private void calc(Button run) {
run.setDisable(true);

if (Utils.fileLocked(ioFile)) {
Alert alert = new Alert(Alert.AlertType.ERROR, "The file is still open, please close it");
Alert alert = new Alert(Alert.AlertType.ERROR, Msg.fileLocked());
alert.setTitle("Problem");
alert.setHeaderText(null);
alert.showAndWait();
Expand All @@ -332,7 +332,7 @@ private void calc(Button run) {
long secondsTimeLimit = timeLimit.getValue() * 60;

if (Utils.fileLocked(ioFile)) {
Alert alert = new Alert(Alert.AlertType.ERROR, "The file is still open, please close it");
Alert alert = new Alert(Alert.AlertType.ERROR, Msg.fileLocked());
alert.setTitle("Problem");
alert.setHeaderText(null);
alert.showAndWait();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/alebolo/rabdomante/xlsx/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public static void close(Closeable... toClose) {

public static boolean fileLocked(File file) {
try {
file.renameTo(file);
return false;
return !file.renameTo(file);
} catch (Exception e) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ resultsheet_searchok=Search completed in
resultsheet_updated_at=Updated @
read_license=Read License
license=License
file_locked=The file is still open, please close it
1 change: 1 addition & 0 deletions src/main/resources/messages_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ resultsheet_searchok=Ricerca completata con successo in
resultsheet_updated_at=Aggiornato @
read_license=Leggi la Licenza
license=Licenza
file_locked=Il file risulta ancora aperto, deve essere chiuso per essere elaborato

0 comments on commit 9194f05

Please sign in to comment.