Skip to content

Commit

Permalink
autocrop cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
othello777 committed Nov 25, 2022
1 parent cf55d1a commit 740c938
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/MyEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ else if(random.nextBoolean())
Thread.sleep(8*1000);
inputMessage.removeReaction("U+2705").queue();
}
DeleteFiles("autocrop");
}

super.onMessageReceived(event);
Expand Down Expand Up @@ -1382,7 +1383,6 @@ private void AutoCropVideo(Message inputMessage) throws InterruptedException, IO
channel.sendMessage("converting").queue();

ProcessBuilder pb = new ProcessBuilder("sh", "autocrop.sh", "autocrop/" + filename);
pb.inheritIO();
pb.directory(new File(System.getProperty("user.dir") + "/bot/"));
pb.start().waitFor();

Expand All @@ -1393,6 +1393,8 @@ private void AutoCropVideo(Message inputMessage) throws InterruptedException, IO
FileReturn ret = new FileReturn();
ret.file = new File(MotorDir, newfilename);
channel.sendMessage(newfilename).addFile(ret.file).queue();

DeleteFiles("autocrop");
}

private void UpdateEconomy() {
Expand Down Expand Up @@ -1513,6 +1515,16 @@ class FileReturn {
int length;
}

private void DeleteFiles(String dir)
{
File filesList[] = new File(System.getProperty("user.dir") + "/bot/" + dir).listFiles();
for(File file : filesList) {
if(file.isFile()) {
file.delete();
}
}
}

private FileReturn getFileFromDir(String dirname, String command) {
File MotorDir = new File(System.getProperty("user.dir") + "/bot/" + dirname);
String contents[] = MotorDir.list();
Expand Down

0 comments on commit 740c938

Please sign in to comment.