summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Zabaluev <mikhail.zabaluev@gmail.com>2015-11-01 19:48:14 +0200
committerMikhail Zabaluev <mikhail.zabaluev@gmail.com>2015-11-01 20:02:46 +0200
commit40d823614a11e9798e6c3f9b70ba957bdaa041ee (patch)
treee7315be2cefc414ea33c0bb7142e091628ab067e
parent1754b3c3011b3795a0bff03bdfdc30c7418b1a62 (diff)
downloadgobject-introspection-40d823614a11e9798e6c3f9b70ba957bdaa041ee.tar.gz
g-ir-scanner: Set sensible permissions on the output file
If the file is new, set the permissions to 0644. If the file with the name specified as --output exists, copy its metadata onto the temporary output file. https://bugzilla.gnome.org/show_bug.cgi?id=757442
-rwxr-xr-xgiscanner/scannermain.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 42466b90..633496fc 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -29,6 +29,7 @@ import errno
import optparse
import os
import shutil
+import stat
import subprocess
import sys
import tempfile
@@ -450,6 +451,13 @@ def write_output(data, options):
output = sys.stdout
elif options.reparse_validate_gir:
main_f, main_f_name = tempfile.mkstemp(suffix='.gir')
+
+ if (os.path.isfile(options.output)):
+ shutil.copystat(options.output, main_f_name)
+ else:
+ os.chmod(main_f_name,
+ stat.S_IWUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
+
with os.fdopen(main_f, 'wb') as main_f:
main_f.write(data)