[niepce: 25/29] rust: fix misc warnings



commit 301bd117333d90360f37d9ffda225e84a772aca6
Author: Hubert Figuière <hub figuiere net>
Date:   Sat Sep 16 21:52:37 2017 -0400

    rust: fix misc warnings

 src/engine/db/filebundle.rs |    4 ++--
 src/engine/db/library.rs    |   30 +++++++++++++++++-------------
 src/fwk/base/date.rs        |    8 +++++++-
 src/fwk/base/debug.rs       |    1 +
 src/fwk/mod.rs              |    2 ++
 5 files changed, 29 insertions(+), 16 deletions(-)
---
diff --git a/src/engine/db/filebundle.rs b/src/engine/db/filebundle.rs
index e7e7528..35f868d 100644
--- a/src/engine/db/filebundle.rs
+++ b/src/engine/db/filebundle.rs
@@ -23,9 +23,9 @@ use std::ffi::CString;
 use std::ffi::OsString;
 use std::path::Path;
 
-use super::libfile::FileType;
+use engine::db::libfile::FileType;
 use fwk::MimeType;
-use root::fwk::FileList;
+use fwk::FileList;
 
 pub struct FileBundle {
     file_type: FileType,
diff --git a/src/engine/db/library.rs b/src/engine/db/library.rs
index df44a48..06a4b57 100644
--- a/src/engine/db/library.rs
+++ b/src/engine/db/library.rs
@@ -34,14 +34,14 @@ use super::{
     FromDb,
     LibraryId
 };
-use super::label::Label;
-use super::libfolder;
-use super::libfolder::LibFolder;
-use super::libfile;
-use super::libfile::LibFile;
-use super::libmetadata::LibMetadata;
-use super::filebundle::FileBundle;
-use super::keyword::Keyword;
+use engine::db::label::Label;
+use engine::db::libfolder;
+use engine::db::libfolder::LibFolder;
+use engine::db::libfile;
+use engine::db::libfile::LibFile;
+use engine::db::libmetadata::LibMetadata;
+use engine::db::filebundle::FileBundle;
+use engine::db::keyword::Keyword;
 use engine::library::notification::Notification as LibNotification;
 use engine::library::notification::engine_library_notify;
 use fwk;
@@ -61,7 +61,7 @@ const DB_SCHEMA_VERSION: i32 = 6;
 const DATABASENAME: &str = "niepcelibrary.db";
 
 pub struct Library {
-    maindir: PathBuf,
+//    maindir: PathBuf,
     dbpath: PathBuf,
     dbconn: Option<rusqlite::Connection>,
     inited: bool,
@@ -74,7 +74,7 @@ impl Library {
         let mut dbpath = dir.clone();
         dbpath.push(DATABASENAME);
         let mut lib = Library {
-            maindir: dir,
+//            maindir: dir,
             dbpath: dbpath,
             dbconn: None,
             inited: false,
@@ -90,11 +90,15 @@ impl Library {
         let conn_attempt = rusqlite::Connection::open(self.dbpath.clone());
         if let Ok(conn) = conn_attempt {
             let notif_id = self.notif_id;
-            conn.create_scalar_function("rewrite_xmp", 0, false, |_| {
+            if let Ok(_) = conn.create_scalar_function("rewrite_xmp", 0, false, |_| {
                 Library::notify_by_id(notif_id, Box::new(LibNotification::XmpNeedsUpdate));
                 Ok(true)
-            });
-            self.dbconn = Some(conn);
+            }) {
+                self.dbconn = Some(conn);
+            } else {
+                err_out!("failed to create scalar functin.");
+                return false;
+            }
         } else {
             return false;
         }
diff --git a/src/fwk/base/date.rs b/src/fwk/base/date.rs
index e252332..9c02d96 100644
--- a/src/fwk/base/date.rs
+++ b/src/fwk/base/date.rs
@@ -35,6 +35,7 @@ pub enum Timezone {}
 /**
  * Class to deal with ISO8601 string dates as used by XMP.
  * Bonus: with a timezone.
+ * XXX replace by chrono::DateTime<>
  */
 pub struct Date {
     datetime: exempi::DateTime,
@@ -53,6 +54,10 @@ impl Date {
         make_xmp_date_time(t, &mut dt);
         Date { datetime: dt, tz: tz }
     }
+
+    pub fn tz(&self) -> &Option<Timezone> {
+        &self.tz
+    }
     pub fn xmp_date(&self) -> &exempi::DateTime {
         &self.datetime
     }
@@ -75,7 +80,8 @@ impl Date {
             tm_zone: ptr::null_mut(),
         };
         let date = unsafe { libc::mktime(&mut dt) };
-        //DBG_ASSERT(date != -1, "date is -1");
+        // XXX can't seem to use the macro here.
+        //dbg_assert!(date != -1, "date is -1");
 
         date
     }
diff --git a/src/fwk/base/debug.rs b/src/fwk/base/debug.rs
index 3730d79..b9d6029 100644
--- a/src/fwk/base/debug.rs
+++ b/src/fwk/base/debug.rs
@@ -33,5 +33,6 @@ mod tests {
     fn it_works() {
         dbg_out!("debug {}", 42);
         err_out!("error {}", 69);
+        dbg_assert!(false, "failed assert");
     }
 }
diff --git a/src/fwk/mod.rs b/src/fwk/mod.rs
index ef0f3e1..0f7a0ea 100644
--- a/src/fwk/mod.rs
+++ b/src/fwk/mod.rs
@@ -39,6 +39,8 @@ pub use self::toolkit::mimetype::{
     MimeType
 };
 
+pub use root::fwk::FileList;
+
 use std::f64;
 use std::ffi::CStr;
 use libc::c_char;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]