[gobject-introspection] g-ir-scanner: Set sensible permissions on the output file



commit 40d823614a11e9798e6c3f9b70ba957bdaa041ee
Author: Mikhail Zabaluev <mikhail zabaluev gmail com>
Date:   Sun Nov 1 19:48:14 2015 +0200

    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

 giscanner/scannermain.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 42466b9..633496f 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)
 


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