1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-05-30 08:36:47 +02:00

Compare commits

..

2 commits

Author SHA1 Message Date
b9f45d148b
Add Nix caches and default flake package 2026-03-31 11:39:07 +02:00
7d2ab89180
Remove temp file using timestamp path
Delete the temp entry at store_path/temp/<timestamp> in both
the hash-exists and success paths. Stop constructing the full filename
with extension and remove the early process::exit to de-duplicate
cleanup.
2026-03-31 10:56:20 +02:00
2 changed files with 17 additions and 9 deletions

View file

@ -1,6 +1,18 @@
{ {
description = "Archivr - An open-source archive manager"; description = "Archivr - An open-source archive manager";
nixConfig = {
extra-substituters = [
"https://cache.thegeneralist01.com/"
"https://cache.garnix.io/"
"https://cache.nixos.org/"
];
extra-trusted-public-keys = [
"cache.thegeneralist01.com:jkKcenR877r7fQuWq6cr0JKv2piqBWmYLAYsYsSJnT4="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];
};
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs = outputs =
@ -21,7 +33,7 @@
pname = "archivr"; pname = "archivr";
version = "0.1.0"; version = "0.1.0";
src = pkgs.lib.cleanSource ./.; src = pkgs.lib.cleanSource ./.;
cargoHash = "sha256-y47+Fmp3BID86aPnLtrvzg40lOr9cHyg/38+onisK7w="; cargoHash = "sha256-4m+4SMYA/rJ0eHEOc32zA2VdZI1pqzB5NenD0R0f2zM=";
nativeBuildInputs = [ pkgs.pkg-config ]; nativeBuildInputs = [ pkgs.pkg-config ];
}; };
archivr = pkgs.stdenv.mkDerivation { archivr = pkgs.stdenv.mkDerivation {
@ -49,6 +61,7 @@
}; };
in in
{ {
default = archivr;
archivr = archivr; archivr = archivr;
archivr-unwrapped = archivr_unwrapped; archivr-unwrapped = archivr_unwrapped;
} }

View file

@ -77,7 +77,7 @@ enum Source {
// INFO: yt-dlp supports a lot of sites; so, when archiving (for example) a website, the user // INFO: yt-dlp supports a lot of sites; so, when archiving (for example) a website, the user
// -> should be asked whether they want to archive the whole website or just the video(s) on it. // -> should be asked whether they want to archive the whole website or just the video(s) on it.
fn determine_source(path: &str) -> Source { fn determine_source(path: &str) -> Source {
// INFO: Extractors' URLs can be found here: // INFO: Extractor URLs can be found here:
// -> https://github.com/yt-dlp/yt-dlp/tree/dfc0a84c192a7357dd1768cc345d590253a14fe5/yt_dlp/extractor // -> https://github.com/yt-dlp/yt-dlp/tree/dfc0a84c192a7357dd1768cc345d590253a14fe5/yt_dlp/extractor
// TEST: X posts can have multiple videos. // TEST: X posts can have multiple videos.
@ -272,13 +272,7 @@ fn main() -> Result<()> {
// Dir or whatever. it's midnight and my brain ain't wording/braining. // Dir or whatever. it's midnight and my brain ain't wording/braining.
if hash_exists { if hash_exists {
println!("File already archived."); println!("File already archived.");
let _ = fs::remove_file( let _ = fs::remove_file(store_path.join("temp").join(&timestamp));
store_path
.join("temp")
.join(&timestamp)
.join(format!("{timestamp}{file_extension}")),
);
process::exit(0);
} else { } else {
move_temp_to_raw( move_temp_to_raw(
&store_path &store_path
@ -288,6 +282,7 @@ fn main() -> Result<()> {
&hash, &hash,
&store_path, &store_path,
)?; )?;
let _ = fs::remove_file(store_path.join("temp").join(&timestamp));
println!("File archived successfully."); println!("File archived successfully.");
} }