Skip to content

Commit d969f01

Browse files
committed
TeeJee.FileSystem.vala: Remove any existing destination file before
attempting to write. Commit 589c2e5 removed the file.delete() call. Unfortunately it is documented that the Gio.FileCreateFlags.REPLACE_DESTINATION flag only works for g_file_replace* methods, not for g_file_create, so users were getting a 'file exists' error. Since there's little chance of any sort of race condition here, just restore the original code, and remove the useless g_file_create flag so we're not fooled again. Fixes #491.
1 parent 02b9ca8 commit d969f01

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Utility/TeeJee.FileSystem.vala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ namespace TeeJee.FileSystem{
171171
dir_create(file_parent(file_path));
172172

173173
var file = File.new_for_path (file_path);
174-
var file_stream = file.create (FileCreateFlags.REPLACE_DESTINATION);
174+
if (file.query_exists ()) {
175+
file.delete ();
176+
}
177+
178+
var file_stream = file.create (FileCreateFlags.NONE);
175179
var data_stream = new DataOutputStream (file_stream);
176180
data_stream.put_string (contents);
177181
data_stream.close();

0 commit comments

Comments
 (0)