Skip to content

Commit

Permalink
Do not synchronize uncessarily with the datafile (#5745)
Browse files Browse the repository at this point in the history
When a JASP file is loaded, it tries always to synchronize with its data file, even if the datafile was not changed: this is because the right dataFile timestamp was not correctly set in the JASP file.
  • Loading branch information
boutinb authored Nov 27, 2024
1 parent aae799b commit e3d0b16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Desktop/data/asyncloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ void AsyncLoader::loadPackage(QString id)

if (_currentEvent->type() != Utils::FileType::jasp)
{
pkg->setDataFilePath(_currentEvent->path().toStdString());
QFileInfo fileInfo(_currentEvent->path());
long timestamp = fileInfo.isFile() ? fileInfo.lastModified().toSecsSinceEpoch() : 0;

pkg->setDataFilePath(_currentEvent->path().toStdString(), timestamp);
pkg->setDatabaseJson(_currentEvent->database());
}

Expand Down
3 changes: 2 additions & 1 deletion Desktop/data/datasetpackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2439,7 +2439,7 @@ bool DataSetPackage::currentFileIsExample() const

void DataSetPackage::setDataFilePath(std::string filePath, long timestamp)
{
if(!_dataSet || _dataSet->dataFilePath() == filePath)
if(!_dataSet || (_dataSet->dataFilePath() == filePath && timestamp == _dataSet->dataFileTimestamp()))
return;

if (timestamp == 0 && !filePath.empty())
Expand All @@ -2452,6 +2452,7 @@ void DataSetPackage::setDataFilePath(std::string filePath, long timestamp)
if (tq(filePath).startsWith(AppDirs::examples()))
setDataFileReadOnly(true);

setModified(true);
emit synchingExternallyChanged(synchingExternally());
}

Expand Down

0 comments on commit e3d0b16

Please sign in to comment.