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 38 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
24 changes: 22 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,28 @@ jobs:
run: gcc -c config/missing_symbols.c -o config/missing_symbols-${{ matrix.os }}.o
- name: Package Drifty GUI for ${{ matrix.os }} with GluonFX maven plugin
run: mvn -Pbuild-drifty-gui-for-${{ matrix.os }} gluonfx:build gluonfx:package
- name: Delete native image configuration files for Linux or macOS
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: rm -rf "src/main/resources/META-INF"
- name: Delete native image configuration files for Windows
if: ${{ matrix.os == 'windows-latest' }}
run: Remove-Item -Recurse -Force "src/main/resources/META-INF"
- name: Package Drifty Updater for ${{ matrix.os }} with GraalVM
run: mvn -Pbuild-drifty-updater-for-${{ matrix.os }} package
- name: Create Application Type specific folders
run: |
mkdir CLI
mkdir GUI
mkdir Updater
- name: Categorise build artifacts for linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
mv "target/CLI/linux/Drifty CLI" "target/CLI/linux/Drifty-CLI_linux"
mv "target/CLI/linux/Drifty-CLI_linux" -t CLI
mv target/gluonfx/x86_64-linux/Drifty "target/gluonfx/x86_64-linux/Drifty-GUI_linux"
mv "target/gluonfx/x86_64-linux/Drifty-GUI_linux" -t GUI
mv "target/Updater/linux/updater" "target/Updater/linux/updater_linux"
mv "target/Updater/linux/updater_linux" -t Updater
- name: Categorise build artifacts for windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
Expand All @@ -83,6 +94,7 @@ jobs:
Rename-Item target/gluonfx/x86_64-windows/Drifty.exe "Drifty-GUI.exe"
move "target/gluonfx/x86_64-windows/Drifty-GUI.msi" GUI
move "target/gluonfx/x86_64-windows/Drifty-GUI.exe" GUI
move "target/Updater/windows/updater.exe" Updater
- name: Categorise build artifacts for macOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
Expand All @@ -92,8 +104,10 @@ jobs:
mv target/gluonfx/x86_64-darwin/Drifty.app "target/gluonfx/x86_64-darwin/Drifty-GUI.app"
mv "target/gluonfx/x86_64-darwin/Drifty-GUI.pkg" GUI
mv "target/gluonfx/x86_64-darwin/Drifty-GUI.app" GUI
mv "target/Updater/macos/updater" "target/Updater/macos/updater_macos"
mv "target/Updater/macos/updater_macos" Updater
- name: Tar build files # To prevent file permission loss
run: tar -cvf ${{ matrix.os }}.tar CLI GUI
run: tar -cvf ${{ matrix.os }}.tar CLI GUI Updater
- name: Push generated artifacts for ${{ matrix.os }}
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -131,6 +145,9 @@ jobs:
echo "CLI_WINDOWS_SIZE=$(echo `du -h 'windows/CLI/Drifty-CLI.exe'` | sed 's/ .*//')" >> "$GITHUB_ENV"
echo "GUI_WINDOWS_MSI_SIZE=$(echo `du -h 'windows/GUI/Drifty-GUI.msi'` | sed 's/ .*//')" >> "$GITHUB_ENV"
echo "GUI_WINDOWS_EXE_SIZE=$(echo `du -h 'windows/GUI/Drifty-GUI.exe'` | sed 's/ .*//')" >> "$GITHUB_ENV"
echo "UPDATER_LINUX_SIZE=$(echo `du -h 'linux/Updater/updater_linux'` | sed 's/ .*//')" >> "$GITHUB_ENV"
echo "UPDATER_MACOS_SIZE=$(echo `du -h 'macos/Updater/updater_macos'` | sed 's/ .*//')" >> "$GITHUB_ENV"
echo "UPDATER_WINDOWS_SIZE=$(echo `du -h 'windows/Updater/updater.exe'` | sed 's/ .*//')" >> "$GITHUB_ENV"
- name: Generate Artifact metadata summary
run: |
echo "# Drifty v$VERSION Built! :rocket:" >> $GITHUB_STEP_SUMMARY
Expand All @@ -141,20 +158,23 @@ jobs:
echo "|------------------|---------------|------|" >> $GITHUB_STEP_SUMMARY
echo "| CLI | Drifty-CLI_linux | $CLI_LINUX_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| GUI | Drifty-GUI_linux | $GUI_LINUX_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| Updater | updater_linux | $UPDATER_LINUX_SIZE |" >> $GITHUB_STEP_SUMMARY

echo "### Artifacts :package: Generated for macOS :apple:" >> $GITHUB_STEP_SUMMARY
echo "| Application Type | Artifact Name | Size |" >> $GITHUB_STEP_SUMMARY
echo "|------------------|---------------|------|" >> $GITHUB_STEP_SUMMARY
echo "| CLI | Drifty-CLI_macos | $CLI_MACOS_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| GUI | Drifty-GUI.pkg | $GUI_MACOS_PKG_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| GUI | Drifty-GUI.app | $GUI_MACOS_APP_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| Updater | updater_macos | $UPDATER_MACOS_SIZE |" >> $GITHUB_STEP_SUMMARY

echo "### Artifacts :package: Generated for Windows :window:" >> $GITHUB_STEP_SUMMARY
echo "| Application Type | Artifact Name | Size |" >> $GITHUB_STEP_SUMMARY
echo "|------------------|---------------|------|" >> $GITHUB_STEP_SUMMARY
echo "| CLI | Drifty-CLI.exe | $CLI_WINDOWS_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| GUI | Drifty-GUI.msi | $GUI_WINDOWS_MSI_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| GUI | Drifty-GUI.exe | $GUI_WINDOWS_EXE_SIZE |" >> $GITHUB_STEP_SUMMARY
echo "| Updater | updater.exe | $UPDATER_WINDOWS_SIZE |" >> $GITHUB_STEP_SUMMARY

if [ ${{ !inputs.create_release }} ]; then
echo "## Release :bookmark: Drifty v$VERSION" >> $GITHUB_STEP_SUMMARY
Expand All @@ -164,7 +184,7 @@ jobs:
if: ${{ inputs.create_release }}
run: |
echo "## Release :bookmark: Drifty v$VERSION" >> $GITHUB_STEP_SUMMARY
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'
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' 'linux/Updater/updater_linux#updater_linux' 'macos/Updater/updater_macos#updater_macos' 'windows/Updater/updater.exe#updater.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 }}
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 @@ -271,6 +271,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
6 changes: 3 additions & 3 deletions src/main/java/Backend/ProgressBarThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ private String generateProgressBar() {
downloadSpeedUnit = "bytes";
}
bar = bar.substring(0, charAmt / 2 - 2) + (formattedTotalDownloadPercent) + "%" + bar.substring(charAmt / 2 + 1);
return "[" + spinner + "] " + fileName + " [" + bar + "](" + UnitConverter.format(totalDownloadedBytes, 2) + ") " + downloadSpeedWithoutUnit + " " + downloadSpeedUnit + "/s";
return "[" + spinner + "] " + fileName + " [" + bar + "](" + UnitConverter.format(downloadedBytes, 2) + "/" + UnitConverter.format(totalDownloadedBytes, 2) + ") " + downloadSpeedWithoutUnit + " " + downloadSpeedUnit + "/s";
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
} 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/CLI/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,4 @@ private static void checkHistoryAddJobsAndDownload(Job job, boolean removeInputB
}
}
}
}
}
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 or GUI) in which Drifty is running
Mode.mode = mode;
}

public static Mode getMode() { // This method returns the mode (CLI or GUI) in which Drifty is running
return mode;
}
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 14 additions & 0 deletions src/main/java/Enums/OS.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public static String getOSName() {
return osName;
}

public static OS getOSType() {
if (osType == null) {
setOSType();
}
return osType;
}

public static boolean isWindows() {
if (osType == null) {
setOSType();
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -46,4 +53,11 @@ public static boolean isMac() {
}
return osType.equals(OS.MAC);
}

public static boolean isLinux() {
if (osType == null) {
setOSType();
}
return osType.equals(OS.LINUX);
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Loading