diff options
| author | diogo464 <[email protected]> | 2025-08-13 11:33:51 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-13 11:33:51 +0100 |
| commit | ca703fd5de303d2101fe2b2a5c0e3037b7507156 (patch) | |
| tree | 7078378ea380b1cfdf502aa62f2e1ada5708ccac /src/main.rs | |
| parent | 74069a896a3b831a19baefc0d9487060b34760b3 (diff) | |
Implement path-based downloads with blob redirect system
- 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 <[email protected]>
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 20 |
1 files changed, 20 insertions, 0 deletions
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 { | |||
| 747 | Import(ImportArgs), | 747 | Import(ImportArgs), |
| 748 | Blob(BlobArgs), | 748 | Blob(BlobArgs), |
| 749 | Log(LogArgs), | 749 | Log(LogArgs), |
| 750 | Stat(StatArgs), | ||
| 750 | } | 751 | } |
| 751 | 752 | ||
| 752 | #[derive(Debug, Args)] | 753 | #[derive(Debug, Args)] |
| @@ -847,6 +848,14 @@ struct LogArgs { | |||
| 847 | common: CliCommon, | 848 | common: CliCommon, |
| 848 | } | 849 | } |
| 849 | 850 | ||
| 851 | #[derive(Debug, Args)] | ||
| 852 | struct StatArgs { | ||
| 853 | #[clap(flatten)] | ||
| 854 | common: CliCommon, | ||
| 855 | |||
| 856 | path: DrivePath, | ||
| 857 | } | ||
| 858 | |||
| 850 | fn main() { | 859 | fn main() { |
| 851 | let cli = Cli::parse(); | 860 | let cli = Cli::parse(); |
| 852 | 861 | ||
| @@ -858,6 +867,7 @@ fn main() { | |||
| 858 | Cmd::Import(args) => cmd_import(args), | 867 | Cmd::Import(args) => cmd_import(args), |
| 859 | Cmd::Blob(args) => cmd_blob(args), | 868 | Cmd::Blob(args) => cmd_blob(args), |
| 860 | Cmd::Log(args) => cmd_log(args), | 869 | Cmd::Log(args) => cmd_log(args), |
| 870 | Cmd::Stat(args) => cmd_stat(args), | ||
| 861 | } | 871 | } |
| 862 | } | 872 | } |
| 863 | 873 | ||
| @@ -1111,6 +1121,16 @@ fn cmd_log(args: LogArgs) { | |||
| 1111 | } | 1121 | } |
| 1112 | } | 1122 | } |
| 1113 | 1123 | ||
| 1124 | fn cmd_stat(args: StatArgs) { | ||
| 1125 | let ops = common_read_log_file(&args.common); | ||
| 1126 | let mut fs = Fs::default(); | ||
| 1127 | ops.iter().for_each(|op| apply(&mut fs, op).unwrap()); | ||
| 1128 | |||
| 1129 | let node_id = find_node(&fs, &args.path).unwrap(); | ||
| 1130 | let node = &fs.nodes[node_id]; | ||
| 1131 | println!("{}", node.blob); | ||
| 1132 | } | ||
| 1133 | |||
| 1114 | fn collect_all_file_paths(root: &Path) -> Vec<PathBuf> { | 1134 | fn collect_all_file_paths(root: &Path) -> Vec<PathBuf> { |
| 1115 | let mut queue = vec![root.to_path_buf()]; | 1135 | let mut queue = vec![root.to_path_buf()]; |
| 1116 | let mut files = vec![]; | 1136 | let mut files = vec![]; |
