[PATCH 23/37] Use expanduser(), check for existence in restoreconfig()

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

 



Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
---
 targetcli/ui_root.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/targetcli/ui_root.py b/targetcli/ui_root.py
index 7148009..487984c 100644
--- a/targetcli/ui_root.py
+++ b/targetcli/ui_root.py
@@ -24,6 +24,7 @@ from ui_target import UIFabricModule
 from ui_backstore import UIBackstores
 import json
 import shutil
+import os
 
 default_save_file = "/etc/target/saveconfig.json"
 
@@ -79,6 +80,8 @@ class UIRoot(UINode):
         '''
         self.assert_root()
 
+        savefile = os.path.expanduser(savefile)
+
         backupfile = savefile + ".backup"
         try:
             shutil.move(savefile, backupfile)
@@ -99,6 +102,12 @@ class UIRoot(UINode):
         '''
         self.assert_root()
 
+        savefile = os.path.expanduser(savefile)
+
+        if not os.path.isfile(savefile):
+            self.shell.log.info("Restore file %s not found" % savefile)
+            return
+
         with open(savefile, "r") as f:
             RTSRoot().restore(json.loads(f.read()), clear_existing)
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux