Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support for updating Drifty #316

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
0792c2c
Added checkUpdate() for Drifty_CLI.
kmr-rohit Oct 22, 2023
ace9e17
Added checkUpdate() for Drifty_CLI.
kmr-rohit Oct 23, 2023
7555e8c
Added checkUpdate() for Drifty_CLI.
kmr-rohit Oct 23, 2023
2eb1def
Added checkUpdate() for Drifty_CLI.
kmr-rohit Oct 23, 2023
f169723
Merge remote-tracking branch 'origin/kmrrohit' into kmrrohit
kmr-rohit Oct 23, 2023
9fc3c11
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 23, 2023
d5b1754
fix: Merge conflicts along with missing symbols fixed
SaptarshiSarkar12 Oct 23, 2023
791f523
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 24, 2023
dfa36ce
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 24, 2023
2501187
Updated Implementation as Suggested.
kmr-rohit Oct 25, 2023
bfdcfd1
Updated Implementation as Suggested.
kmr-rohit Oct 25, 2023
8d0a476
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 25, 2023
aa81c94
fix: Fixed merge conflicts and removed redundancy from Updater class …
SaptarshiSarkar12 Oct 25, 2023
4e30a4c
fix(ci): Fixed wrong directory name for updater package
SaptarshiSarkar12 Oct 26, 2023
80c106a
fix: Fixed linter and build ci issues
SaptarshiSarkar12 Oct 26, 2023
0f813ca
Merge branch 'kmrrohit' of https://github.com/kmr-rohit/Drifty into k…
SaptarshiSarkar12 Oct 26, 2023
06f63d6
fix: Fixed CI build issues and renamed some method parameters
SaptarshiSarkar12 Oct 26, 2023
4211d08
Merge branch 'master' into kmrrohit
kmr-rohit Oct 26, 2023
77399b0
fix: Fixed null pointer and IO exception in Updater class for log fil…
SaptarshiSarkar12 Oct 26, 2023
4de0370
Merge branch 'kmrrohit' of https://github.com/kmr-rohit/Drifty into k…
SaptarshiSarkar12 Oct 26, 2023
e0c6b07
fix: Removed test parameter from updater class
SaptarshiSarkar12 Oct 26, 2023
6accde5
fix: Added old executable delete call
SaptarshiSarkar12 Oct 26, 2023
61ffe93
fix: Removed `java.awt` and added `process.waitFor()` to wait for the…
SaptarshiSarkar12 Oct 26, 2023
9c83ea6
fix: Fixed duplicate log lines
SaptarshiSarkar12 Oct 26, 2023
b8b94ce
fix: Update for Drifty CLI and GUI working now
SaptarshiSarkar12 Oct 27, 2023
caf91e7
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 27, 2023
35fa35d
fix: Fixed linter issues
SaptarshiSarkar12 Oct 27, 2023
21cc2ff
fix: Fixed linter issues
SaptarshiSarkar12 Oct 27, 2023
3d3710e
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 30, 2023
6325fc1
fix: Fixed maven build error
SaptarshiSarkar12 Oct 30, 2023
a4b6453
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 30, 2023
61f2273
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 30, 2023
b944038
Merge branch 'SaptarshiSarkar12:master' into kmrrohit
kmr-rohit Oct 31, 2023
7cea908
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 31, 2023
5f20535
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 31, 2023
0ea3d8e
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Oct 31, 2023
e7d9df9
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 10, 2023
65d40ec
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 18, 2023
f9281a5
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 18, 2023
c3df06a
fix: Fixed build issues
SaptarshiSarkar12 Nov 18, 2023
857057a
fix: Fixed build issues
SaptarshiSarkar12 Nov 18, 2023
3160303
chore: Updated comments in Mode enum
SaptarshiSarkar12 Nov 18, 2023
4fb45bc
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 19, 2023
fdaacba
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
dfee770
fix: Fixed compilation failure: "Final variable can not be re-assigned"
SaptarshiSarkar12 Nov 20, 2023
f12640e
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
3dee47f
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
27695ff
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
0148bbc
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
08d7a54
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
3322c02
Commit message
github-actions[bot] Nov 20, 2023
a41e997
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
4f17fb2
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
e143312
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
82dc774
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
c3fa99f
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
a754e19
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
c9890cc
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
5370a6a
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
f77d1d5
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
c829e02
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 20, 2023
c8615ea
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 21, 2023
eb9be77
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 21, 2023
29fb6aa
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 21, 2023
537ff4e
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 21, 2023
33916d2
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 23, 2023
a0f00cc
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 23, 2023
28ddff9
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 23, 2023
d233778
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 23, 2023
44797bc
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 23, 2023
d48b5a5
chore: Added some spaces in Utility class to test if formatter works
SaptarshiSarkar12 Nov 23, 2023
2e2eb48
style: Formatted Java files
github-actions[bot] Nov 23, 2023
62f5ec8
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 23, 2023
beee02d
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 24, 2023
5bf83d4
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 24, 2023
71101f7
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 24, 2023
13d1aa5
style: Formatted Java files
github-actions[bot] Nov 24, 2023
2024e90
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 27, 2023
d1e5557
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 28, 2023
03a896f
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 28, 2023
3e504e1
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Nov 29, 2023
76ec1c6
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Dec 2, 2023
03f2a28
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Dec 2, 2023
2a0d597
Merge branch 'master' into kmrrohit
SaptarshiSarkar12 Dec 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ jobs:
gh release create v$VERSION --generate-notes 'linux/CLI/Drifty-CLI_linux#Drifty-CLI_linux' 'linux/GUI/Drifty-GUI_linux#Drifty-GUI_linux' 'macos/CLI/Drifty-CLI_macos#Drifty-CLI_macos' 'macos/GUI/Drifty-GUI.pkg#Drifty-GUI.pkg' 'windows/CLI/Drifty-CLI.exe#Drifty-CLI.exe' 'windows/GUI/Drifty-GUI.msi#Drifty-GUI.msi' 'windows/GUI/Drifty-GUI.exe#Drifty-GUI.exe'
echo "[Released :white_check_mark: Drifty v$VERSION](https://github.com/SaptarshiSarkar12/Drifty/releases/tag/v$VERSION) successfully :rocket:!" >> $GITHUB_STEP_SUMMARY
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,107 @@
</plugins>
</build>
</profile>
<!-- [Linux] Updater native image builder profile -->
<profile>
<id>build-drifty-updater-for-ubuntu-latest</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<imageName>updater</imageName>
<mainClass>Updater.Updater</mainClass>
<outputDirectory>target/Updater/linux</outputDirectory>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>-march=compatibility</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
<buildArg>--verbose</buildArg>
</buildArgs>
</configuration>
<executions>
<execution>
<id>build</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- [macOS] Updater native image builder profile -->
<profile>
<id>build-drifty-updater-for-macos-latest</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<imageName>updater</imageName>
<mainClass>Updater.Updater</mainClass>
<outputDirectory>target/Updater/macos</outputDirectory>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>-march=compatibility</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
<buildArg>--verbose</buildArg>
</buildArgs>
</configuration>
<executions>
<execution>
<id>build</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- [Windows] Updater native image builder profile -->
<profile>
<id>build-drifty-updater-for-windows-latest</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<imageName>updater</imageName>
<mainClass>Updater.Updater</mainClass>
<outputDirectory>target/Updater/windows</outputDirectory>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
<buildArg>--verbose</buildArg>
</buildArgs>
</configuration>
<executions>
<execution>
<id>build</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- [macOS] GUI native image builder profile -->
<profile>
<id>build-drifty-gui-for-macos-latest</id>
Expand Down
27 changes: 5 additions & 22 deletions src/main/java/Backend/CopyExecutables.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;

public class CopyExecutables {
private static final MessageBroker M = Environment.getMessageBroker();
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -23,26 +23,9 @@ public final void copyExecutables(final String[] executableNames) throws IOExcep
if (!executablePath.toFile().getParentFile().exists()) {
FileUtils.createParentDirectories(executablePath.toFile());
}
try (OutputStream outputStream = Files.newOutputStream(executablePath)) {
if (inputStream != null) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
}
if (!Files.isExecutable(executablePath)) {
ProcessBuilder makeExecutable = new ProcessBuilder("chmod", "+x", executablePath.toString());
makeExecutable.inheritIO();
Process chmod = makeExecutable.start();
chmod.waitFor();
}
} catch (FileAlreadyExistsException e) {
M.msgLogWarning(executableName + " not copied to " + Program.get(Program.DRIFTY_PATH) + " because it already exists!");
} catch (InterruptedException e) {
M.msgLogWarning("Failed to make " + executableName + " executable: " + e.getMessage());
} catch (IOException e) {
M.msgInitError("Failed to copy " + executableName + " executable: " + e.getMessage());
Files.copy(inputStream, executablePath);
if (!Files.isExecutable(executablePath)) {
Files.setPosixFilePermissions(executablePath, Set.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE));
}
}
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/Backend/FileDownloader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Backend;

import Enums.Mode;
import Enums.Program;
import Utils.Environment;
import Utils.MessageBroker;
Expand Down Expand Up @@ -88,7 +89,9 @@ private void downloadFile() {
}
ProgressBarThread progressBarThread = new ProgressBarThread(fileOutputStreams, partSizes, fileName, getDir(), totalSize, downloadMetrics);
progressBarThread.start();
M.msgDownloadInfo(String.format(DOWNLOADING_F, fileName));
if (!Mode.isUpdating()) {
M.msgDownloadInfo(String.format(DOWNLOADING_F, fileName));
}
// check if all the files are downloaded
while (!mergeDownloadedFileParts(fileOutputStreams, partSizes, downloaderThreads, tempFiles)) {
sleep(500);
Expand Down Expand Up @@ -186,7 +189,6 @@ public boolean mergeDownloadedFileParts(List<FileOutputStream> fileOutputStreams
public void run() {
boolean isYouTubeLink = isYoutube(link);
boolean isInstagramLink = isInstagram(link);
boolean isSpotifyLink = isSpotify(link);
try {
// If the link is of a YouTube or Instagram video, then the following block of code will execute.
if (isYouTubeLink || isInstagramLink) {
Expand All @@ -201,8 +203,6 @@ public void run() {
} catch (Exception e) {
if (isYouTubeLink) {
M.msgDownloadError(YOUTUBE_DOWNLOAD_FAILED);
} else if (isSpotifyLink) {
M.msgDownloadError(SPOTIFY_DOWNLOAD_FAILED);
} else {
M.msgDownloadError(INSTAGRAM_DOWNLOAD_FAILED);
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public void run() {
String[] webPaths = url.getFile().trim().split("/");
fileName = webPaths[webPaths.length - 1];
}
M.msgDownloadInfo("Trying to download \"" + fileName + "\" ...");
M.msgLogInfo("Trying to download \"" + fileName + "\" ...");
downloadFile();
}
} catch (MalformedURLException | URISyntaxException e) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/Backend/ProgressBarThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private String generateProgressBar() {
return "[" + spinner + "] " + fileName + " [" + bar + "](" + UnitConverter.format(totalDownloadedBytes, 2) + ") " + downloadSpeedWithoutUnit + " " + downloadSpeedUnit + "/s";
} else {
int numberOfThreads = fileOutputStreams.size();
StringBuilder result = new StringBuilder("[" + spinner + "] " + UnitConverter.format(totalDownloadedBytes, 2));
StringBuilder result = new StringBuilder("[" + spinner + "] " + fileName + " ");
float filled;
totalDownloadedBytes = 0;
long downloadSpeed = 0;
Expand Down Expand Up @@ -144,7 +144,7 @@ private String generateProgressBar() {
downloadSpeedWithoutUnit = 0;
downloadSpeedUnit = "bytes";
}
result.append(" [").append(bar).append("] ").append(String.format("%.2f", downloadSpeedWithoutUnit)).append(" ").append(downloadSpeedUnit).append("/s");
result.append(" [").append(bar).append("] (").append(UnitConverter.format(totalDownloadedBytes, 2)).append("/").append(UnitConverter.format(totalSizeOfTheFile, 2)).append(") ").append(String.format("%.2f", downloadSpeedWithoutUnit)).append(" ").append(downloadSpeedUnit).append("/s");
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
return result.toString();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Enums/MessageCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* This class is used to provide a category to the message that is sent to the Message Broker.
*/
public enum MessageCategory {
LINK, DIRECTORY, DOWNLOAD, FILENAME, LOG, INITIALIZATION, STYLE, BATCH, SETTINGS
LINK, DIRECTORY, DOWNLOAD, FILENAME, LOG, INITIALIZATION, STYLE, BATCH, SETTINGS, UPDATE
}
20 changes: 18 additions & 2 deletions src/main/java/Enums/Mode.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package Enums;

/**
* This enum class specifies whether Drifty is opened in <b>GUI</b> or <b>CLI</b> mode
* This enum class specifies whether Drifty is opened in <b>GUI</b> or <b>CLI</b> or <b>UPDATE</b> mode.
*/
public enum Mode {
CLI, GUI;
CLI, GUI, UPDATE;

private static Mode mode = Mode.CLI;

Expand All @@ -19,4 +19,20 @@ public static boolean isGUI() {
public static boolean isCLI() {
return mode.equals(Mode.CLI);
}

public static void setUpdateMode() {
Mode.mode = Mode.UPDATE;
}

public static boolean isUpdating() {
return mode.equals(Mode.UPDATE);
}

public static void setMode(Mode mode) { // This method is used to set the mode (CLI, GUI, or UPDATE) in which Drifty is running
Mode.mode = mode;
}

public static Mode getMode() { // This method returns the mode (CLI, GUI, or UPDATE) in which Drifty is running
return mode;
}
}
6 changes: 5 additions & 1 deletion src/main/java/Enums/OS.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static void setOSType() {
}
}

private static OS getOSType() {
public static OS getOSType() {
if (osType == null) {
setOSType();
}
Expand All @@ -44,4 +44,8 @@ public static boolean isWindows() {
public static boolean isMac() {
return getOSType().equals(OS.MAC);
}

public static boolean isLinux() {
return getOSType().equals(OS.LINUX);
}
}
8 changes: 4 additions & 4 deletions src/main/java/GUI/Forms/FormsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ private void setControlProperties() {
setFilename(job.getFilename());
selectJob(job);
});
form.cbAutoPaste.setSelected(AppSettings.GET.mainAutoPaste());
form.cbAutoPaste.selectedProperty().addListener(((observable, oldValue, newValue) -> AppSettings.SET.mainAutoPaste(newValue)));
form.cbAutoPaste.setSelected(AppSettings.GET.autoPaste());
form.cbAutoPaste.selectedProperty().addListener(((observable, oldValue, newValue) -> AppSettings.SET.autoPaste(newValue)));
form.tfDir.textProperty().addListener(((observable, oldValue, newValue) -> {
if (!newValue.equals(oldValue)) {
DIRECTORY_EXISTS.setValue(false);
Expand Down Expand Up @@ -376,7 +376,7 @@ private Runnable getFilenames(String link) {
We use the checkHistoryAddJobs method to look for discovered filenames. If we didn't do it this way, then we would need
to wait until all filenames are discovered then add the jobs to the batch list in one action. Doing it this way
gives the user more consistent feedback of the process while it is happening. This matters when a link contains
a lot of files because each file discovered takes a while, and when there are even hundreds of files, this process
a lot of files because each file discovered takes a while. When there are even hundreds of files, this process
can appear to take a long time, so constant feedback for the user becomes relevant.
*/

Expand Down Expand Up @@ -630,7 +630,7 @@ public static void resetDownloadFoldersToActiveList() {
INSTANCE.folders = AppSettings.GET.folders();
}

public static boolean isAutoPaste() {
public static boolean isAutoPasteEnabled() {
return form.cbAutoPaste.isSelected() || AppSettings.GET.alwaysAutoPaste();
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/GUI/Forms/GetFilename.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import static Utils.Utility.sleep;

public class GetFilename extends Task<ConcurrentLinkedDeque<Job>> {
private final String regex = "(\\[download] Downloading item \\d+ of )(\\d+)";
private final String link;
private final String dir;
private final String regex = "(\\[download] Downloading item \\d+ of )(\\d+)";
private final Pattern pattern = Pattern.compile(regex);
private final String lineFeed = System.lineSeparator();
private int result = -1;
Expand Down Expand Up @@ -67,7 +67,7 @@ protected ConcurrentLinkedDeque<Job> call() {
timer.scheduleAtFixedRate(getJson(), 1000, 150);
Utility.getLinkMetadata(link);
timer.cancel();
sleep(500); //give timerTask enough time to do its last run
sleep(500); // give timerTask enough time to do its last run
jobList.clear();
FormsController.setDownloadInfoColor(Colors.GREEN);
updateMessage("File(s) added to batch.");
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -124,7 +124,6 @@ public void run() {
};
}


private TimerTask runProgress() {
return new TimerTask() {
@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/GUI/Forms/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void createScene() {
firstRun = false;
return;
}
if (FormsController.isAutoPaste()) {
if (FormsController.isAutoPasteEnabled()) {
Clipboard clipboard = Clipboard.getSystemClipboard();
if (clipboard.hasString()) {
String clipboardText = clipboard.getString();
Expand Down Expand Up @@ -107,7 +107,7 @@ private Menu getMenuItemsOfMenu() {
return menu;
}

private MenuBar menuBar(Menu... menus) {
private MenuBar menuBar(Menu ...menus) {
return new MenuBar(menus);
}

Expand Down
14 changes: 11 additions & 3 deletions src/main/java/GUI/Support/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import java.nio.file.Path;
import java.nio.file.Paths;

import static Utils.Utility.cleanFilename;
import static Utils.Utility.randomString;

/**
* This is a data structure class for batch jobs. It holds the relevant information for a batch job
*/
public class Job {
private final String link;
private final String dir;
private final String filename;
private String filename;
private boolean repeatDownload;

public Job(String link, String dir, String filename, boolean repeatDownload) {
Expand Down Expand Up @@ -60,8 +63,13 @@ public boolean fileExists() {
}

private String getName() {
String[] nameParts = link.split("/");
return nameParts[nameParts.length - 1];
String file = link.substring(link.lastIndexOf("/") + 1);
if (file.isEmpty()) {
return cleanFilename("Unknown_Filename_") + randomString(15);
}
// file.png?width=200 -> file.png
filename = file.split("([?])")[0];
return filename;
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
}

public boolean repeatOK() {
Expand Down
Loading