Skip to content

Commit

Permalink
[projectview] fix: sqlite db cache on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jd28 committed Sep 23, 2024
1 parent 4cbe23c commit 71b1adf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/widgets/projectview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,15 @@ void ProjectModel::walkDirectory(const QString& path, ProjectItem* parent)
res = nw::Resource::from_path(p.toStdString());
if (res.valid()) {
auto meta = getMetadata(p);
if (!meta.lastModified.isValid() || fileInfo.lastModified() > meta.lastModified) {
bool insert = false;
if (meta.lastModified.isValid()) {
qint64 lastModifiedOnDiskEpoch = fileInfo.lastModified().toMSecsSinceEpoch();
qint64 dbLastModifiedEpoch = meta.lastModified.toMSecsSinceEpoch();
insert = lastModifiedOnDiskEpoch > dbLastModifiedEpoch;
} else {
insert = true;
}
if (insert) {
meta.object_name = read_object_name(p);
meta.size = fileInfo.size();
meta.lastModified = fileInfo.lastModified();
Expand Down Expand Up @@ -262,7 +270,7 @@ ProjectItemMetadata ProjectModel::getMetadata(const QString& path)
return metadata;
}

if (sqlite3_bind_text(stmt, 1, path.toStdString().c_str(), -1, SQLITE_STATIC) != SQLITE_OK) {
if (sqlite3_bind_text(stmt, 1, path.toUtf8().constData(), -1, SQLITE_STATIC) != SQLITE_OK) {
LOG_F(ERROR, "Failed to bind parameter: {}", sqlite3_errmsg(db_));
return metadata;
}
Expand Down

0 comments on commit 71b1adf

Please sign in to comment.