[Merge] lp:~artmello/gallery-app/gallery-app-fix_1445755 into lp:gallery-app

Bill Filler bill.filler at canonical.com
Fri Sep 2 13:57:11 UTC 2016



Diff comments:

> 
> === modified file 'src/database/media-table.cpp'
> --- src/database/media-table.cpp	2015-01-14 15:19:05 +0000
> +++ src/database/media-table.cpp	2016-08-30 19:07:34 +0000
> @@ -225,12 +226,62 @@
>      return exposure_time;
>  }
>  
> +void MediaTable::removeBlacklistedRows()
> +{
> +    if (!m_resource)
> +        return;
> +
> +    // Get list of current /media external drives connected
> +    QString extDrivesPath("/media/" + qgetenv("USER") + "/");
> +    if (!QDir(extDrivesPath).exists())
> +        return;

we probably shouldn't return here if there are no external drives. Because what about the case where user changes the conf file and removes the external drive stuff but has other entries, then those entries will never be removed from database.

> +
> +    QStringList extDrives = QDir(extDrivesPath).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time);
> +
> +    // Expand current regular expressions to use existing external drives
> +    QStringList replacedRegExpList;
> +    foreach (const QString& regExp, m_resource->blacklistedDirectories()) {
> +        // If regular expression is a valid path add that to the support LIKE format
> +        if (QDir(regExp).exists()) {
> +            replacedRegExpList << regExp + "%";
> +            continue;
> +        }
> +
> +        // If regular expression is in the default format replace it with sdcard path
> +        if (!regExp.startsWith("/media/" + qgetenv("USER") + "/[^/]*"))
> +            continue;
> +
> +        foreach (const QString &extDrive, extDrives) {
> +            QString replacedRegExp(regExp);
> +            replacedRegExp.replace("/media/" + qgetenv("USER") + "/[^/]*", "/media/" + qgetenv("USER") + "/" + extDrive);
> +
> +            if (replacedRegExp.endsWith("/")) {
> +                replacedRegExpList << replacedRegExp + "%";
> +            } else {
> +                replacedRegExpList << replacedRegExp + "/%";
> +            }
> +        }
> +    }
> +
> +    QSqlQuery query(*m_db->getDB());
> +    query.prepare("DELETE FROM MediaTable WHERE filename LIKE :blacklisted");
> +
> +    foreach (const QString &blacklisted, replacedRegExpList) {
> +        query.bindValue(":blacklisted", blacklisted);
> +        if (!query.exec()) {
> +            m_db->logSqlError(query);
> +        }
> +    }
> +}
> +
>  /*!
>   * \brief MediaTable::emitAllRows goes through the whole DB and emits a row() signal
>   * for every single row with all the Database
>   */
>  void MediaTable::emitAllRows()
>  {
> +    removeBlacklistedRows();
> +
>      QSqlQuery query(*m_db->getDB());
>      query.prepare("SELECT * FROM MediaTable");
>      if (!query.exec())


-- 
https://code.launchpad.net/~artmello/gallery-app/gallery-app-fix_1445755/+merge/304034
Your team Ubuntu Phablet Team is requested to review the proposed merge of lp:~artmello/gallery-app/gallery-app-fix_1445755 into lp:gallery-app.



More information about the Ubuntu-reviews mailing list