changeset 311:dbecbde2d8a2

db_impl: Move lock file methods around.
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 28 Sep 2017 20:43:53 +0200
parents cec9661bb363
children e2e8ce2a9434
files src/db_impl.rs
diffstat 1 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/db_impl.rs	Thu Sep 28 20:43:33 2017 +0200
+++ b/src/db_impl.rs	Thu Sep 28 20:43:53 2017 +0200
@@ -113,31 +113,6 @@
         Ok(db)
     }
 
-    /// acquire_lock acquires the lock file.
-    fn acquire_lock(&mut self) -> Result<()> {
-        let lock_r = self.opt.env.lock(Path::new(&lock_file_name(&self.name)));
-        match lock_r {
-            Ok(lockfile) => {
-                self.lock = Some(lockfile);
-                Ok(())
-            }
-            Err(ref e) if e.code == StatusCode::LockError => {
-                err(StatusCode::LockError,
-                    "database lock is held by another instance")
-            }
-            Err(e) => Err(e),
-        }
-    }
-
-    /// release_lock releases the lock file, if it's currently held.
-    fn release_lock(&mut self) -> Result<()> {
-        if let Some(l) = self.lock.take() {
-            self.opt.env.unlock(l)
-        } else {
-            Ok(())
-        }
-    }
-
     /// initialize_db initializes a new database.
     fn initialize_db(&mut self) -> Result<()> {
         let mut ve = VersionEdit::new();
@@ -334,6 +309,31 @@
         }
         Ok(())
     }
+
+    /// acquire_lock acquires the lock file.
+    fn acquire_lock(&mut self) -> Result<()> {
+        let lock_r = self.opt.env.lock(Path::new(&lock_file_name(&self.name)));
+        match lock_r {
+            Ok(lockfile) => {
+                self.lock = Some(lockfile);
+                Ok(())
+            }
+            Err(ref e) if e.code == StatusCode::LockError => {
+                err(StatusCode::LockError,
+                    "database lock is held by another instance")
+            }
+            Err(e) => Err(e),
+        }
+    }
+
+    /// release_lock releases the lock file, if it's currently held.
+    fn release_lock(&mut self) -> Result<()> {
+        if let Some(l) = self.lock.take() {
+            self.opt.env.unlock(l)
+        } else {
+            Ok(())
+        }
+    }
 }
 
 impl DB {