diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-02-17 15:54:09 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-02-17 15:54:09 +0100 |
| commit | b03dd6f20aa3a8ae9c0347b3a34d8b581182ff68 (patch) | |
| tree | 9e6cec11163cfc34efdfec534a983e67b9a9c331 | |
| parent | 6719d6e187c5da06ffff8b7eff10151c7855a935 (diff) | |
| download | jellything-b03dd6f20aa3a8ae9c0347b3a34d8b581182ff68.tar jellything-b03dd6f20aa3a8ae9c0347b3a34d8b581182ff68.tar.bz2 jellything-b03dd6f20aa3a8ae9c0347b3a34d8b581182ff68.tar.zst | |
improve db import debug; fix inverted mtime check
| -rw-r--r-- | common/src/internal.rs | 12 | ||||
| -rw-r--r-- | common/src/lib.rs | 2 | ||||
| -rw-r--r-- | import/src/lib.rs | 14 |
3 files changed, 19 insertions, 9 deletions
diff --git a/common/src/internal.rs b/common/src/internal.rs new file mode 100644 index 0000000..94876f1 --- /dev/null +++ b/common/src/internal.rs @@ -0,0 +1,12 @@ +/* + 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) 2026 metamuffin <metamuffin.org> +*/ + +use jellyobject::fields; + +fields! { + IM_PATH: &str = 0x11001 "path"; + IM_MTIME: u64 = 0x11002 "mtime"; +} diff --git a/common/src/lib.rs b/common/src/lib.rs index 4ae098d..4f8ffca 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -4,6 +4,7 @@ Copyright (C) 2025 metamuffin <metamuffin.org> */ pub mod api; +pub mod internal; pub mod node; pub mod routes; pub mod user; @@ -25,6 +26,7 @@ pub static TAGREG: LazyLock<Registry> = LazyLock::new(|| { user::register_fields(&mut reg); api::register_fields(&mut reg); api::register_enums(&mut reg); + internal::register_fields(&mut reg); reg }); diff --git a/import/src/lib.rs b/import/src/lib.rs index 7980451..da72232 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -15,6 +15,7 @@ use crate::{ use anyhow::{Context, Result, anyhow}; use jellycache::{Cache, HashKey}; use jellycommon::{ + internal::{IM_MTIME, IM_PATH}, jellyobject::{self, ObjectBuffer, Path as TagPath, fields}, *, }; @@ -76,11 +77,6 @@ pub struct ImportConfig { pub db: Arc<dyn Database>, } -fields! { - IM_PATH: &str = 0x11001 "path"; - IM_MTIME: u64 = 0x11002 "mtime"; -} - fn node_slug_query(slug: &str) -> Query { Query { filter: Filter::Match(jellyobject::Path(vec![NO_SLUG.0]), slug.as_bytes().to_vec()), @@ -265,7 +261,7 @@ fn import_traverse( && let Some(parent) = parent { if incremental { - if compare_mtime(ic, path)? { + if !compare_mtime(ic, path)? { return Ok(()); } } @@ -439,7 +435,7 @@ fn compare_mtime(dba: &ImportConfig, path: &Path) -> Result<bool> { match txn.query_single(Query { filter: Filter::Match( TagPath(vec![IM_PATH.0]), - path.as_os_str().as_encoded_bytes().to_vec(), + path.to_string_lossy().as_bytes().to_vec(), ), sort: Sort::None, })? { @@ -462,14 +458,14 @@ fn update_mtime(dba: &ImportConfig, path: &Path) -> Result<()> { let row = match txn.query_single(Query { filter: Filter::Match( TagPath(vec![IM_PATH.0]), - path.as_os_str().as_encoded_bytes().to_vec(), + path.to_string_lossy().as_bytes().to_vec(), ), sort: Sort::None, })? { Some(row) => row, None => txn.insert(ObjectBuffer::new(&mut [( IM_PATH.0, - &path.as_os_str().as_encoded_bytes(), + &path.to_string_lossy().as_bytes(), )]))?, }; |