Summary: | Allow matching library paths across different operating systems? | ||
---|---|---|---|
Product: | [Applications] digikam | Reporter: | Hampton <k4kfh.radio> |
Component: | Database-Mysql | Assignee: | Digikam Developers <digikam-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | caulier.gilles, metzpinguin, nrv9999, spam-receiver |
Priority: | NOR | ||
Version: | 5.7.0 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | All | ||
Latest Commit: | https://invent.kde.org/graphics/digikam/commit/6a630aeab30849225015826aa185cc8a8516cc74 | Version Fixed In: | 8.0.0 |
Sentry Crash Report: | |||
Attachments: | multiOSAlbumRoots.patch |
Description
Hampton
2017-09-18 17:47:38 UTC
I also get this bug.. unrealised functionality. If you add collection from one machine, and add that collection (with such name) from another, digikam understand this as 2 different collection and scan twice (also metadata will not synchronize if it not stored in EXIF). Looking at db structure, I see that collections identifier is full path, that different on Windows and Linux, it can be different on two Windows machines. But presents column "specificPath". I do next thing: MariaDB [digikam]> select * from AlbumRoots; +----+-------+--------+------+------------------------------------+-----------------------------------------------------------+ | id | label | status | type | identifier | specificPath | +----+-------+--------+------+------------------------------------+-----------------------------------------------------------+ | 8 | disc | 0 | 3 | networkshareid:?mountpath=Pictures | //bananapi/disc/ | | 9 | disc | 0 | 3 | networkshareid:?mountpath=Pictures | /run/user/1000/gvfs/smb-share:server=bananapi,share=disc/ | +----+-------+--------+------+------------------------------------+--------------------------------------------------- So identifiers are same. I hoped, that digikam will concat it (specificPath + mountpath). It didn't. It not see my collection. Created attachment 117218 [details]
multiOSAlbumRoots.patch
This patch solves the problem. The database columns "identifier" and "specificPath" become a string list. A new path can be defined under the respective operating system with the new collection update function. It would be nice if someone could test the patch.
Maik
Maik, How you patch preserve the compatibility with previous collections recorded in database. A migration is done after to apply the patch and run digiKam ? Gilles Yes, the function has no problems with existing "old" entries. But I will update the patch again. Maik Hi Maik, what's the plan for this patch ? Gilles *** Bug 456749 has been marked as a duplicate of this bug. *** Comment on attachment 117218 [details] multiOSAlbumRoots.patch >diff --git a/core/libs/database/coredb/coredb.cpp b/core/libs/database/coredb/coredb.cpp >index 227a1ce63c..153c4125ec 100644 >--- a/core/libs/database/coredb/coredb.cpp >+++ b/core/libs/database/coredb/coredb.cpp >@@ -53,6 +53,7 @@ extern "C" > > // Local includes > >+#include "digikam_config.h" > #include "digikam_debug.h" > #include "coredbbackend.h" > #include "collectionmanager.h" >@@ -61,6 +62,14 @@ extern "C" > #include "tagscache.h" > #include "album.h" > >+#ifdef Q_OS_WIN >+ static const char* DK_CURRENT_OS = "WIN:"; >+#elif defined Q_OS_OSX >+ static const char* DK_CURRENT_OS = "OSX:"; >+#else >+ static const char* DK_CURRENT_OS = "LNX:"; >+#endif >+ > namespace Digikam > { > >@@ -191,9 +200,9 @@ QList<AlbumRootInfo> CoreDB::getAlbumRoots() > ++it; > info.type = (AlbumRoot::Type)(*it).toInt(); > ++it; >- info.identifier = (*it).toString(); >+ info.identifier = decodeOSString((*it).toString()); > ++it; >- info.specificPath = (*it).toString(); >+ info.specificPath = decodeOSString((*it).toString()); > ++it; > > list << info; >@@ -205,9 +214,14 @@ QList<AlbumRootInfo> CoreDB::getAlbumRoots() > int CoreDB::addAlbumRoot(AlbumRoot::Type type, const QString& identifier, const QString& specificPath, const QString& label) > { > QVariant id; >+ QString osIdentifier = identifier; >+ QString osSpecificPath = specificPath; >+ osIdentifier.prepend(QLatin1String(DK_CURRENT_OS)); >+ osSpecificPath.prepend(QLatin1String(DK_CURRENT_OS)); >+ > d->db->execSql(QString::fromUtf8("REPLACE INTO AlbumRoots (type, label, status, identifier, specificPath) " > "VALUES(?, ?, 0, ?, ?);"), >- (int)type, label, identifier, specificPath, 0, &id); >+ (int)type, label, osIdentifier, osSpecificPath, 0, &id); > > d->db->recordChangeset(AlbumRootChangeset(id.toInt(), AlbumRootChangeset::Added)); > return id.toInt(); >@@ -230,8 +244,14 @@ void CoreDB::deleteAlbumRoot(int rootId) > > void CoreDB::migrateAlbumRoot(int rootId, const QString& identifier) > { >+ QList<QVariant> values; >+ >+ d->db->execSql(QString::fromUtf8("SELECT identifier FROM AlbumRoots " >+ "WHERE id=?;"), >+ rootId, &values); >+ > d->db->execSql(QString::fromUtf8("UPDATE AlbumRoots SET identifier=? WHERE id=?;"), >- identifier, rootId); >+ encodeOSString(values, identifier), rootId); > d->db->recordChangeset(AlbumRootChangeset(rootId, AlbumRootChangeset::PropertiesChanged)); > } > >@@ -251,8 +271,14 @@ void CoreDB::changeAlbumRootType(int rootId, AlbumRoot::Type newType) > > void CoreDB::setAlbumRootPath(int rootId, const QString& newPath) > { >+ QList<QVariant> values; >+ >+ d->db->execSql(QString::fromUtf8("SELECT specificPath FROM AlbumRoots " >+ "WHERE id=?;"), >+ rootId, &values); >+ > d->db->execSql(QString::fromUtf8("UPDATE AlbumRoots SET specificPath=? WHERE id=?;"), >- newPath, rootId); >+ encodeOSString(values, newPath), rootId); > d->db->recordChangeset(AlbumRootChangeset(rootId, AlbumRootChangeset::PropertiesChanged)); > } > >@@ -5029,4 +5055,49 @@ void CoreDB::writeSettings() > group.writeEntry(d->configRecentlyUsedTags, d->recentlyAssignedTags); > } > >+QString CoreDB::decodeOSString(const QString& str) >+{ >+ QStringList list = str.split(QLatin1Char(';')); >+ QString osString = str; >+ >+ foreach (const QString& s, list) >+ { >+ if (s.startsWith(QLatin1String(DK_CURRENT_OS))) >+ { >+ osString = s.mid(4); >+ break; >+ } >+ } >+ >+ return osString; >+} >+ >+QString CoreDB::encodeOSString(const QList<QVariant>& values, const QString& str) >+{ >+ QString osString; >+ >+ if (values.size() == 1) >+ { >+ QStringList list = values.first().toString().split(QLatin1Char(';')); >+ >+ foreach (const QString& s, list) >+ { >+ if (s.startsWith(QLatin1String(DK_CURRENT_OS)) || s == str) >+ { >+ continue; >+ } >+ >+ osString.append(s).append(QLatin1Char(';')); >+ } >+ >+ osString.append(QLatin1String(DK_CURRENT_OS)).append(str); >+ } >+ else >+ { >+ osString = str; >+ } >+ >+ return osString; >+} >+ > } // namespace Digikam >diff --git a/core/libs/database/coredb/coredb.h b/core/libs/database/coredb/coredb.h >index ad507f9b11..c8cd498759 100644 >--- a/core/libs/database/coredb/coredb.h >+++ b/core/libs/database/coredb/coredb.h >@@ -1392,6 +1392,9 @@ private: > void readSettings(); > void writeSettings(); > >+ QString decodeOSString(const QString& str); >+ QString encodeOSString(const QList<QVariant>& values, const QString& str); >+ > private: > > class Private; Git commit 6a630aeab30849225015826aa185cc8a8516cc74 by Maik Qualmann. Committed on 16/07/2022 at 15:14. Pushed by mqualmann into branch 'master'. add support for alternate network paths in the collection view Related: bug 456749 FIXED-IN: 8.0.0 M +3 -1 NEWS M +4 -0 core/libs/database/collection/collectionlocation.h M +6 -3 core/libs/database/collection/collectionmanager.h M +5 -3 core/libs/database/collection/collectionmanager_location.cpp M +7 -2 core/libs/database/collection/collectionmanager_p.cpp M +2 -3 core/libs/database/collection/collectionmanager_p.h M +206 -17 core/utilities/setup/collections/setupcollectionview.cpp M +21 -8 core/utilities/setup/collections/setupcollectionview.h https://invent.kde.org/graphics/digikam/commit/6a630aeab30849225015826aa185cc8a8516cc74 |