diff options
| author | metamuffin <metamuffin@disroot.org> | 2025-12-11 15:42:11 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2025-12-11 15:42:11 +0100 |
| commit | da1c8a7202fa75a2e9521dbdd04d6846dcec40ec (patch) | |
| tree | 04b5042f196eb15963f2101360ec06dca434188d | |
| parent | 36391b074f2fb20de77dbc23573ca5b8fbf7f0d5 (diff) | |
| download | jellything-da1c8a7202fa75a2e9521dbdd04d6846dcec40ec.tar jellything-da1c8a7202fa75a2e9521dbdd04d6846dcec40ec.tar.bz2 jellything-da1c8a7202fa75a2e9521dbdd04d6846dcec40ec.tar.zst | |
rocksdb cache tools
| -rw-r--r-- | cache/src/bin/cache_fs_to_rocksdb.rs | 1 | ||||
| -rw-r--r-- | cache/src/bin/cache_rocksdb_delete_prefix.rs | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/cache/src/bin/cache_fs_to_rocksdb.rs b/cache/src/bin/cache_fs_to_rocksdb.rs index 0a3b43d..0c9900c 100644 --- a/cache/src/bin/cache_fs_to_rocksdb.rs +++ b/cache/src/bin/cache_fs_to_rocksdb.rs @@ -16,6 +16,7 @@ fn main() -> Result<()> { bail!("path needs to end with /") } traverse(&db, &in_path, in_path.as_ref())?; + db.flush()?; Ok(()) } diff --git a/cache/src/bin/cache_rocksdb_delete_prefix.rs b/cache/src/bin/cache_rocksdb_delete_prefix.rs new file mode 100644 index 0000000..1245f74 --- /dev/null +++ b/cache/src/bin/cache_rocksdb_delete_prefix.rs @@ -0,0 +1,25 @@ +/* + This file is part of jellything (https://codeberg.org/metamuffin/jellything) + which is licensed under the GNU Affero General Public License (version 3); see /COPYING. + Copyright (C) 2025 metamuffin <metamuffin.org> +*/ + +use anyhow::Result; +use rocksdb::DB; +use std::env::args; + +fn main() -> Result<()> { + let db = DB::open_default(args().nth(1).unwrap())?; + let prefix = args().nth(2).unwrap(); + for r in db.prefix_iterator(&prefix) { + let key = r?.0; + let key_s = String::from_utf8_lossy(&key); + if !key_s.starts_with(&prefix) { + break; + } + println!("{key_s}"); + db.delete(key)?; + } + db.flush()?; + Ok(()) +} |