[rygel] core: Save posted data to a temporary file



commit d7bffab888ebea06447b9c3e86e64a4037568814
Author: Jens Georg <mail jensge org>
Date:   Mon Sep 19 11:59:34 2011 +0200

    core: Save posted data to a temporary file
    
    Ensure that no spurious file-system events will cause premature
    updating of the meta-data

 src/rygel/rygel-http-post.vala |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/rygel/rygel-http-post.vala b/src/rygel/rygel-http-post.vala
index 6e50782..c9a5b75 100644
--- a/src/rygel/rygel-http-post.vala
+++ b/src/rygel/rygel-http-post.vala
@@ -32,6 +32,7 @@ internal class Rygel.HTTPPost : HTTPRequest {
     SourceFunc handle_continue;
 
     File file;
+    File dotfile;
     OutputStream stream;
 
     public HTTPPost (HTTPServer   http_server,
@@ -73,7 +74,9 @@ internal class Rygel.HTTPPost : HTTPRequest {
                                          this.item.id);
         }
 
-        this.stream = yield this.file.replace_async
+        this.dotfile = this.file.get_parent ().get_child
+                                        ("." + this.file.get_basename ());
+        this.stream = yield this.dotfile.replace_async
                                         (null,
                                          false,
                                          FileCreateFlags.REPLACE_DESTINATION,
@@ -130,6 +133,25 @@ internal class Rygel.HTTPPost : HTTPRequest {
             return false;
         });
 
+        try {
+            this.dotfile.move (this.file,
+                               FileCopyFlags.NONE,
+                               this.cancellable);
+        } catch (Error move_error) {
+            // translators: Dotfile is the filename with prefix "."
+            warning (_("Failed to move dotfile %s: %s"),
+                     this.dotfile.get_uri (),
+                     move_error.message);
+
+            Source.remove (timeout_id);
+            this.item.parent.disconnect (id);
+            this.server.unpause_message (this.msg);
+            this.end (KnownStatusCode.INTERNAL_SERVER_ERROR);
+            this.handle_continue ();
+
+            return;
+        }
+
         yield;
 
         this.item.parent.disconnect (id);



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