Skip to content

Commit

Permalink
Merge pull request #193 from bharathkalyans/code-review-and-refactoring
Browse files Browse the repository at this point in the history
Removed redundant code and other refactoring
  • Loading branch information
SaptarshiSarkar12 committed Jan 4, 2023
2 parents ed0caf9 + f996dec commit cbb136f
Show file tree
Hide file tree
Showing 14 changed files with 585 additions and 371 deletions.
15 changes: 15 additions & 0 deletions .idea/checkstyle-idea.xml

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

31 changes: 31 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

31 changes: 31 additions & 0 deletions .idea/sonarlint/issuestore/index.pb

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

10 changes: 5 additions & 5 deletions Website/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fetch(
});

function download_alert_window() {
var w = confirm("Do you want to download Drifty?");
if (w == true) {
let w = confirm("Do you want to download Drifty?");
if (w === true) {
alert("Thanks for Downloading");
window.open(
"https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty_CLI.exe"
Expand All @@ -25,8 +25,8 @@ function download_alert_window() {
}

function download_alert_apple() {
var a = confirm("Do you want to download Drifty?");
if (a == true) {
let a = confirm("Do you want to download Drifty?");
if (a === true) {
alert("Thanks for Downloading");
window.open(
"https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty.jar"
Expand Down Expand Up @@ -248,7 +248,7 @@ function toggleMore(btn, id) {
function renderAssets(assets) {
return assets.reduce((all, asset) => {
//check if it is for windows
let is_windows = asset.name.split(".").pop().toLocaleLowerCase() == "exe";
let is_windows = asset.name.split(".").pop().toLocaleLowerCase() === "exe";

if (is_windows) {
return `${all} <a href="${asset.browser_download_url}">Download <i class="fab fa-windows"></i></a>`;
Expand Down
10 changes: 6 additions & 4 deletions src/CheckDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.nio.file.Files;
import java.nio.file.Path;

import static constants.DriftyConstants.*;

/**
* This class checks if a directory exists or not. if it doesn't, the directory is created.
*/
Expand All @@ -14,10 +16,10 @@ class CheckDirectory {
* @throws IOException when creating the directory fails.
*/
CheckDirectory(String dir) throws IOException {
if (!(checkIfFolderExists(dir))){
if (!(checkIfFolderExists(dir))) {
Path directory = FileSystems.getDefault().getPath(dir);
Files.createDirectory(directory);
Drifty_CLI.logger.log("INFO", "Directory Created");
Drifty_CLI.logger.log(LOGGER_INFO, DIRECTORY_CREATED);
}
}

Expand All @@ -34,8 +36,8 @@ private static boolean checkIfFolderExists(String folderName) {
found = true;
}
} catch (Exception e) {
System.out.println("Error while checking for directory !");
Drifty_CLI.logger.log("ERROR", "Error while checking for directory !");
System.out.println(ERROR_WHILE_CHECKING_FOR_DIRECTORY);
Drifty_CLI.logger.log(LOGGER_ERROR, ERROR_WHILE_CHECKING_FOR_DIRECTORY);
}
return found;
}
Expand Down
14 changes: 7 additions & 7 deletions src/DownloaderThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

public class DownloaderThread extends Thread{
public class DownloaderThread extends Thread {

private URL url;
private FileOutputStream file;
private long start;
private long end;
private final URL url;
private final long start;
private final long end;
private final FileOutputStream file;

public DownloaderThread(URL url, FileOutputStream file, long start, long end) {
this.url=url;
this.url = url;
this.file = file;
this.start = start;
this.end = end;
Expand All @@ -24,7 +24,7 @@ public void run() {
ReadableByteChannel readableByteChannel;
try {
URLConnection con = url.openConnection();
con.setRequestProperty("Range", "bytes="+start+"-"+end);
con.setRequestProperty("Range", "bytes=" + start + "-" + end);
con.connect();
readableByteChannel = Channels.newChannel(con.getInputStream());
file.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
Expand Down
Loading

0 comments on commit cbb136f

Please sign in to comment.