Skip to content

Commit

Permalink
Improve file exists bug
Browse files Browse the repository at this point in the history
Less chance of file exists bug happening
  • Loading branch information
Jordfoz16 committed Dec 2, 2018
1 parent aade7ed commit ba037c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,15 @@ public void correctTitle(String title, int season, int episode) {
correctTitle(title, season, null, episode);
}

public void rename(int starting) {
for(int i = starting; i < videoFiles.size(); i++) {
public void rename() {
for(int i = videoFiles.size() - 1; i >= 0; i--) {
utils.renameFile(videoFiles.get(i));
}
for(int i = starting; i < subtitleFiles.size(); i++) {
for(int i = subtitleFiles.size() - 1; i >= 0; i--) {
utils.renameFile(subtitleFiles.get(i));
}
}

public void rename() {
rename(0);
}


public void clear() {
videoFiles.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void renameFile(MediaFile mediafile) {

if(file.renameTo(newFile)) {
}else {
System.out.println("Failed!!");
System.out.println("File already exists");
}
}

Expand Down

0 comments on commit ba037c6

Please sign in to comment.