From ca703fd5de303d2101fe2b2a5c0e3037b7507156 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Wed, 13 Aug 2025 11:33:51 +0100 Subject: Implement path-based downloads with blob redirect system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add fctdrive stat command to get blob IDs from paths - Add Drive_stat function to drive_server.ts for backend integration - Create /download/[...path] endpoint that redirects to /blob/{blobId} - Update UI file links to use /download/ paths instead of direct blob links - Update permalinks to use immutable /blob/{blobId} URLs - Fix host preservation in redirects for remote access 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/main.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 6431a88..ebbc817 100644 --- a/src/main.rs +++ b/src/main.rs @@ -747,6 +747,7 @@ enum Cmd { Import(ImportArgs), Blob(BlobArgs), Log(LogArgs), + Stat(StatArgs), } #[derive(Debug, Args)] @@ -847,6 +848,14 @@ struct LogArgs { common: CliCommon, } +#[derive(Debug, Args)] +struct StatArgs { + #[clap(flatten)] + common: CliCommon, + + path: DrivePath, +} + fn main() { let cli = Cli::parse(); @@ -858,6 +867,7 @@ fn main() { Cmd::Import(args) => cmd_import(args), Cmd::Blob(args) => cmd_blob(args), Cmd::Log(args) => cmd_log(args), + Cmd::Stat(args) => cmd_stat(args), } } @@ -1111,6 +1121,16 @@ fn cmd_log(args: LogArgs) { } } +fn cmd_stat(args: StatArgs) { + let ops = common_read_log_file(&args.common); + let mut fs = Fs::default(); + ops.iter().for_each(|op| apply(&mut fs, op).unwrap()); + + let node_id = find_node(&fs, &args.path).unwrap(); + let node = &fs.nodes[node_id]; + println!("{}", node.blob); +} + fn collect_all_file_paths(root: &Path) -> Vec { let mut queue = vec![root.to_path_buf()]; let mut files = vec![]; -- cgit