[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeextragear-3/digikam/digikam
From:       Renchi Raju <renchi () pooh ! tam ! uiuc ! edu>
Date:       2005-04-21 17:19:16
Message-ID: 20050421171916.0F41662C () office ! kde ! org
[Download RAW message or body]

CVS commit by pahlibar: 



copy digikam.db in albumlibrary path to digikam-testing.db . During the 
initial experimental phase of 0_8 development, this will be the db file 
being used (so that developers can safely work on their main album library
path without risk of clobbering their db)
CCMAIL: digikam-devel@lists.sourceforge.net


  M +2 -1      albummanager.cpp   1.17
  M +55 -4     main.cpp   1.45


--- kdeextragear-3/digikam/digikam/albummanager.cpp  #1.16:1.17
@@ -171,5 +171,6 @@ void AlbumManager::setLibraryPath(const 
     d->libraryPath = path;
 
-    QString dbPath = path + "/digikam.db";
+    //TODO: rename back to digikam.db for production code
+    QString dbPath = path + "/digikam-testing.db";
 
 #ifdef NFS_HACK

--- kdeextragear-3/digikam/digikam/main.cpp  #1.44:1.45
@@ -30,4 +30,5 @@
 #include <qstringlist.h>
 #include <qfileinfo.h>
+#include <qfile.h>
 
 // KDE includes
@@ -58,4 +59,43 @@ extern "C"
 #include "digikamfirstrun.h"
 
+// TODO: Only for testing purposes for 0.8 development. Remove
+// for production version
+static bool copyDBFile(const QString& albumLibraryPath)
+{
+    QFile sFile(albumLibraryPath + "/digikam.db");
+    QFile dFile(albumLibraryPath + "/digikam-testing.db");
+
+    if (!sFile.exists() || dFile.exists())
+        return true;
+
+    if (!sFile.open(IO_ReadOnly))
+        return false;
+    
+    if (!dFile.open(IO_WriteOnly))
+    {
+        sFile.close();
+        return false;
+    }
+
+    const int MAX_IPC_SIZE = (1024*32);
+    char buffer[MAX_IPC_SIZE];
+
+    Q_LONG len;
+    while ((len = sFile.readBlock(buffer, MAX_IPC_SIZE)) != 0)
+    {
+        if (len == -1 || dFile.writeBlock(buffer, (Q_ULONG)len) == -1)
+        {
+            sFile.close();
+            dFile.close();
+            return false;
+        }
+    }
+
+    sFile.close();
+    dFile.close();
+    
+    return true;
+}
+
 static KCmdLineOptions options[] =
 {
@@ -66,11 +106,11 @@ static KCmdLineOptions options[] =
 int main(int argc, char *argv[])
 {
-    QString Description = i18n("A Photo-Management Application for KDE") + "\n" + 
+    QString description = i18n("A Photo-Management Application for KDE") + "\n" + 
                           i18n("Using Kipi library version %1").arg(kipi_version);
     
     KAboutData aboutData( "digikam", 
                           I18N_NOOP("digiKam"),
-                          digikam_version,        // Release number available in \
                version.h to the top source dir.
-                          Description.latin1(),
+                          digikam_version,        
+                          description.latin1(),
                           KAboutData::License_GPL,
                           I18N_NOOP("(c) 2002-2005, Digikam developers team"),
@@ -194,5 +234,5 @@ int main(int argc, char *argv[])
     
     KCmdLineArgs::init( argc, argv, &aboutData );
-    KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+    KCmdLineArgs::addCmdLineOptions( options ); 
 
     KApplication app;
@@ -255,4 +295,15 @@ int main(int argc, char *argv[])
     }
     
+    // copy the db to a new temp file. we will use this copied db for testing
+    // purposes in 0.8 development. just a safety precautions for developers
+    // working on their main photo library
+
+    if (!copyDBFile(albumPath))
+    {
+        KMessageBox::error(0, i18n("Failed to copy database file "
+                                   "to temporary one."));
+        return 0;
+    }
+    
     
     // Register image formats (especially for TIFF )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic