Bug 99896 - Copying images destroys file date
Summary: Copying images destroys file date
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Scan (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-21 00:24 UTC by Johannes Stallkamp
Modified: 2023-04-08 20:56 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 8.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Stallkamp 2005-02-21 00:24:46 UTC
Version:           digikam 0.7 (using KDE KDE 3.3.2)
OS:                Linux

Copying images between two albums "destroys" (i.e. does not properly set) the file date of the copy. Since Digikam uses the file's modifications date to sort images by date instead of the EXIF date, the copied file's modification date should be set according to the original image.
Comment 1 Renchi Raju 2005-02-21 05:37:25 UTC
CVS commit by pahlibar: 



when copying files over, set the file modification time to that of src file
BUG: 99896


  M +25 -0     digikamio.cpp   1.11


--- kdeextragear-3/digikam/kioslave/digikamio.cpp  #1.10:1.11
@@ -45,4 +45,5 @@ extern "C" 
 #include <sys/time.h>
 #include <time.h>
+#include <utime.h>
 #include <errno.h>
 #include <sqlite.h>
@@ -412,4 +413,16 @@ void kio_digikamioProtocol::copyInternal
                      .arg(oldDirID)
                      .arg(escapeString(src.fileName())) );
+
+            // also set the filetime to that of the original file
+            struct utimbuf t;
+            t.actime  = buff_src.st_atime;
+            t.modtime = buff_src.st_mtime;
+
+            if ( ::utime( _dest.data(), &t ) != 0 )
+            {
+                kdWarning() << k_funcinfo
+                            << "Failed to set datetime of destination file "
+                            << "to that of of original file" << endl;
+            }
         }
 
@@ -447,4 +460,16 @@ void kio_digikamioProtocol::copyInternal
             return;
         }
+
+        // also set the filetime to that of the original file
+        struct utimbuf t;
+        t.actime  = buff_src.st_atime;
+        t.modtime = buff_src.st_mtime;
+
+        if ( ::utime( _dest.data(), &t ) != 0 )
+        {
+            kdWarning() << k_funcinfo
+                        << "Failed to set datetime of destination file "
+                        << "to that of of original file" << endl;
+        }
     }
 }