From: Jens Georg Date: Mon, 19 Sep 2011 09:59:34 +0000 (+0200) Subject: core: Save posted data to a temporary file X-Git-Tag: RYGEL_0_13_0~100 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7bffab888ebea06447b9c3e86e64a4037568814;p=profile%2Fivi%2Frygel.git core: Save posted data to a temporary file Ensure that no spurious file-system events will cause premature updating of the meta-data --- 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);