mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Always perform fallback document size discovery in fileprovideritemmetadata
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
3b179cc1a1
commit
1d01f67790
2 changed files with 11 additions and 13 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "fileprovideritemmetadata.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
@ -94,6 +95,15 @@ FileProviderItemMetadata FileProviderItemMetadata::fromNSFileProviderItem(const
|
|||
metadata._userVisiblePath = metadata.getUserVisiblePath();
|
||||
metadata._fileTypeString = QString::fromNSString(bridgedNsFileProviderItem.contentType.localizedDescription);
|
||||
|
||||
if (metadata._documentSize == 0) {
|
||||
// If the document size is 0, we can try to get the size of the file
|
||||
// directly from its path. These are all materialised files anyway
|
||||
// so the size will be properly represented
|
||||
const auto path = metadata.userVisiblePath();
|
||||
const auto fileInfo = QFileInfo(path);
|
||||
metadata._documentSize = fileInfo.size();
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,20 +103,8 @@ QVariant FileProviderMaterialisedItemsModel::data(const QModelIndex &index, int
|
|||
case FileTypeStringRole:
|
||||
return item.fileTypeString();
|
||||
case FileSizeStringRole:
|
||||
{
|
||||
const auto docSize = item.documentSize();
|
||||
if (docSize > 0) {
|
||||
return _locale.formattedDataSize(item.documentSize());
|
||||
}
|
||||
|
||||
// If the document size is 0, we can try to get the size of the file
|
||||
// directly from its path. These are all materialised files anyway
|
||||
// so the size will be properly represented
|
||||
const auto path = item.userVisiblePath();
|
||||
const auto fileInfo = QFileInfo(path);
|
||||
return _locale.formattedDataSize(fileInfo.size());
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue