Alon Bar-Lev has uploaded a new change for review.

Change subject: core: filetransaction: return original file name if content is 
same
......................................................................

core: filetransaction: return original file name if content is same

Change-Id: I64aa6db80f4804fc2b0ec88a8757430966e15659
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M src/otopi/filetransaction.py
1 file changed, 7 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/16/11516/1

diff --git a/src/otopi/filetransaction.py b/src/otopi/filetransaction.py
index 15834c5..1abc09d 100644
--- a/src/otopi/filetransaction.py
+++ b/src/otopi/filetransaction.py
@@ -88,7 +88,10 @@
 
     @property
     def tmpname(self):
-        return self._tmpname
+        if self._originalDiffer:
+            return self._tmpname
+        else:
+            return self._name
 
     @classmethod
     def registerAtomicMove(clz, function):
@@ -166,6 +169,7 @@
         self._backup = None
         self._originalFileWasMissing = not os.path.exists(self._name)
         self._prepared = False
+        self._originalDiffer = True
 
     def __str__(self):
         return _("File transaction for '{file}'").format(
@@ -173,7 +177,6 @@
         )
 
     def prepare(self):
-        doit = True
         if self._originalFileWasMissing:
             self.logger.debug("file '%s' missing" % self._name)
         else:
@@ -183,9 +186,9 @@
                     self.logger.debug(
                         "file '%s' already has content" % self._name
                     )
-                    doit = False
+                    self._originalDiffer = False
 
-        if doit:
+        if self._originalDiffer:
             mydir = os.path.dirname(self._name)
             if self._originalFileWasMissing:
                 if not os.path.exists(mydir):


--
To view, visit http://gerrit.ovirt.org/11516
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64aa6db80f4804fc2b0ec88a8757430966e15659
Gerrit-PatchSet: 1
Gerrit-Project: otopi
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to