Skip to content

Commit

Permalink
chore: Changed .config to .drifty directory for storing Drifty's …
Browse files Browse the repository at this point in the history
…data in macOS/Linux
  • Loading branch information
SaptarshiSarkar12 committed Oct 23, 2023
1 parent e0b4d96 commit 36960de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ For **Users** :
> [!IMPORTANT]
> - To download files in your local directory, you need to pass that directory as a volume to Drifty.
> Suppose, you want to download the file in your `home/username/Downloads` directory, then, the volume flag that you need to pass to docker will be `-v /home/username/Downloads:/root/Downloads`.
> - You can pass `-v /home/username/.drifty:/root/.config` to enable the docker container to store the Drifty's data in your local directory, making initialization of Drifty much faster 🚀.
> - You can pass `-v /home/username/.drifty:/root/.drifty` to enable the docker container to store the Drifty's data in your local directory, making initialization of Drifty much faster 🚀.
> - For **Linux**, it is advisable to use **Docker Engine** directly instead of running images using **Docker Desktop**. You can do the same by adding **_`sudo`_** before the docker commands.

1. Pull the Docker image for Drifty using the below command -
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
container_name: drifty-cli
volumes:
- ${DOWNLOAD_FOLDER:-.}:/root/Downloads
- ./.drifty:/root/.config
- ./.drifty:/root/.drifty
gui:
depends_on:
- base
Expand All @@ -39,4 +39,4 @@ services:
volumes:
- ${DOWNLOAD_FOLDER:-.}:/root/Downloads
- /tmp/.X11-unix:/tmp/.X11-unix
- ./.drifty:/root/.config
- ./.drifty:/root/.drifty
23 changes: 12 additions & 11 deletions src/main/java/Utils/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@ public class Environment {
*/
public static void initializeEnvironment() {
M.msgLogInfo("OS : " + OS.getOSName());
String ytDLP = OS.isWindows() ? "yt-dlp.exe" : OS.isMac() ? "yt-dlp_macos" : "yt-dlp";
String spotdl = OS.isWindows() ? "spotdl_win.exe" : OS.isMac() ? "spotdl_macos" : "spotdl_linux";
String appUseFolderPath = OS.isWindows() ? Paths.get(System.getenv("LOCALAPPDATA"), "Drifty").toAbsolutePath().toString() : Paths.get(System.getProperty("user.home"), ".config", "Drifty").toAbsolutePath().toString();
Program.setYt_DlpExecutableName(ytDLP);
Program.setSpotdlExecutableName(spotdl);
Program.setDriftyPath(appUseFolderPath);
String ytDlpExecName = OS.isWindows() ? "yt-dlp.exe" : OS.isMac() ? "yt-dlp_macos" : "yt-dlp";
String spotDLExecName = OS.isWindows() ? "spotdl_win.exe" : OS.isMac() ? "spotdl_macos" : "spotdl_linux";
String driftyFolderPath = OS.isWindows() ? Paths.get(System.getenv("LOCALAPPDATA"), "Drifty").toAbsolutePath().toString() : Paths.get(System.getProperty("user.home"), ".drifty").toAbsolutePath().toString();
Program.setYt_DlpExecutableName(ytDlpExecName);
Program.setSpotdlExecutableName(spotDLExecName);
Program.setDriftyPath(driftyFolderPath);
CopyExecutables copyExecutables = new CopyExecutables();
boolean ytDLPExists = false;
try {
copyExecutables.copyExecutables(new String[]{ytDLP, spotdl});
copyExecutables.copyExecutables(new String[]{ytDlpExecName, spotDLExecName});
} catch (IOException e) {
M.msgInitError("Failed to copy yt-dlp! " + e.getMessage());
M.msgInitError("Failed to copy spotDL! " + e.getMessage());
}
if (ytDLPExists && !isYtDLPUpdated()) {
updateYt_dlp();
}
File folder = new File(appUseFolderPath);
File folder = new File(driftyFolderPath);
if (!folder.exists()) {
try {
Files.createDirectory(folder.toPath());
M.msgInitInfo("Created Drifty folder : " + appUseFolderPath);
M.msgInitInfo("Created Drifty folder : " + driftyFolderPath);
} catch (IOException e) {
M.msgInitError("Failed to create Drifty folder: " + appUseFolderPath + " - " + e.getMessage());
M.msgInitError("Failed to create Drifty folder: " + driftyFolderPath + " - " + e.getMessage());
}
} else {
M.msgInitInfo("Drifty folder already exists : " + appUseFolderPath);
M.msgInitInfo("Drifty folder already exists : " + driftyFolderPath);
}
}

Expand Down Expand Up @@ -77,6 +77,7 @@ public static boolean isYtDLPUpdated() {
long timeSinceLastUpdate = System.currentTimeMillis() - AppSettings.get.lastDLPUpdateTime();
return timeSinceLastUpdate <= oneDay;
}

public static MessageBroker getMessageBroker() {
return M;
}
Expand Down

1 comment on commit 36960de

@vercel
Copy link

@vercel vercel bot commented on 36960de Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.