From d7bffab888ebea06447b9c3e86e64a4037568814 Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Mon, 19 Sep 2011 11:59:34 +0200 Subject: [PATCH] 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 file changed, 23 insertions(+), 1 deletion(-) 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); -- 2.7.4