Store fetched folder as private member in filedetails
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 21 Oct 2024 06:54:34 +0000 (14:54 +0800)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 21 Nov 2024 08:57:39 +0000 (09:57 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/filedetails/filedetails.cpp
src/gui/filedetails/filedetails.h

index 67ebb554cec29e2a23075794d1324f223ec9c0c8..e7897aaf5f92b0c418389780b18a353f084b553e 100644 (file)
@@ -61,15 +61,15 @@ void FileDetails::setLocalPath(const QString &localPath)
     _fileWatcher.addPath(localPath);
     connect(&_fileWatcher, &QFileSystemWatcher::fileChanged, this, &FileDetails::refreshFileDetails);
 
-    const auto folder = FolderMan::instance()->folderForPath(_localPath);
-    if (!folder) {
+    _folder = FolderMan::instance()->folderForPath(_localPath);
+    if (!_folder) {
         qCWarning(lcFileDetails) << "No folder found for path:" << _localPath << "will not load file details.";
         return;
     }
 
-    const auto file = _localPath.mid(folder->cleanPath().length() + 1);
+    const auto file = _localPath.mid(_folder->cleanPath().length() + 1);
 
-    if (!folder->journalDb()->getFileRecord(file, &_fileRecord)) {
+    if (!_folder->journalDb()->getFileRecord(file, &_fileRecord)) {
         qCWarning(lcFileDetails) << "Invalid file record for path:"
                                  << _localPath
                                  << "will not load file details.";
@@ -77,9 +77,9 @@ void FileDetails::setLocalPath(const QString &localPath)
 
     _filelockState = _fileRecord._lockstate;
     updateLockExpireString();
-    updateFileTagModel(folder);
 
-    _sharingAvailable = folder->accountState()->account()->capabilities().shareAPI();
+    const auto account = _folder->accountState()->account();
+    _sharingAvailable = account->capabilities().shareAPI();
 
     Q_EMIT fileChanged();
 }
index 2834981afb7686133279a39e08bd59c851770d50..a4dc7e5931ceb96e8ac5511a27d5747e19ce7e12 100644 (file)
@@ -73,6 +73,7 @@ private:
 
     QFileInfo _fileInfo;
     QFileSystemWatcher _fileWatcher;
+    Folder *_folder = nullptr;
     SyncJournalFileRecord _fileRecord;
     SyncJournalFileLockInfo _filelockState;
     QByteArray _numericFileId;