Bug 113914 - Image permissions are restricted after saving.
Summary: Image permissions are restricted after saving.
Status: CLOSED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: ImageEditor-Save (show other bugs)
Version: 0.8.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-05 21:38 UTC by Tung NGUYEN
Modified: 2022-02-03 04:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 7.5.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tung NGUYEN 2005-10-05 21:38:42 UTC
Version:           0.8.0-beta2 (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources
OS:                Linux

After modifying and saving an image, permissions "rw-rw-rw" become "rw------" with the Image Editor and "rw-r--r-" with ShowFoto. Is it possible not to touch these permission after saving ?
Comment 1 Renchi Raju 2005-10-06 04:22:22 UTC
SVN commit 467716 by pahlibar:

preserve permissions when doing save/saveAs

BUGS: 113914


 M  +19 -1     imlibinterface.cpp  


--- trunk/extragear/graphics/digikam/utilities/imageeditor/imlibinterface.cpp #467715:467716
@@ -26,6 +26,9 @@
 extern "C" 
 {
 #include <tiffio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 }
  
 // C++ includes.
@@ -99,6 +102,7 @@
     Imlib_Color_Modifier cmod;
     Imlib_Load_Error     errorRet;
     QString              filename;
+    mode_t               filePermissions;
 
     UndoManager*         undoMan;
 };
@@ -189,6 +193,7 @@
     d->gamma      = 1.0;
     d->contrast   = 1.0;
     d->brightness = 0.0;
+    d->filePermissions = 0;
 
     imlib_context_set_color_modifier(d->cmod);
     imlib_reset_color_modifier();
@@ -219,7 +224,14 @@
         }
     }
 
-    if (d->image) {
+    if (d->image)
+    {
+        struct stat stbuf;
+        if (::stat(QFile::encodeName(filename), &stbuf) == 0)
+        {
+            d->filePermissions = stbuf.st_mode;
+        }
+        
         imlib_context_set_image(d->image);
         imlib_image_set_changes_on_disk();
 
@@ -1007,6 +1019,12 @@
         return false;  // Do not reload the file if saving failed !
     }
 
+    // file saved. now preserve the permissions
+    if (d->filePermissions != 0)
+    {
+        ::chmod(QFile::encodeName(saveFile), d->filePermissions);
+    }
+
     return true;
 }
 
Comment 2 Tung NGUYEN 2005-10-07 13:36:47 UTC
I have tested this bug fix with the lastest SVN, permissions are now preserved after saving. 
   
Thank you. 
Comment 3 caulier.gilles 2005-10-07 13:38:25 UTC
Fixed by Renchi. Closed.

Gilles