Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/source/backend/dropped_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,11 @@ std::optional<SharedData::DroppedItem> droppedItemFromPath(std::filesystem::path
.name = name ? name->value() : std::string{},
.type = droppedTypeOf(path, status),
};
if (entry.isRegularFile())
{
std::error_code sizeError{};
const auto size = std::filesystem::file_size(path, sizeError);
entry.size = sizeError ? 0u : size;
}
return SharedData::DroppedItem{.path = *std::move(localPath), .entry = std::move(entry)};
}
17 changes: 15 additions & 2 deletions backend/source/backend/sftp/operation_queue.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <backend/sftp/operation_queue.hpp>
#include <constants/sftp.hpp>
#include <utility/error_message.hpp>
#include <utility/localized_message.hpp>
#include <backend/rpc_helper.hpp>
Expand Down Expand Up @@ -33,6 +34,16 @@ using namespace std::chrono_literals;

namespace
{
/**
* @brief The size of the file at @p path, 0 when it cannot be read.
*/
std::uintmax_t localFileSize(std::filesystem::path const& path)
{
std::error_code error{};
const auto size = std::filesystem::file_size(path, error);
return error ? 0u : size;
}

/**
* @brief No path instead of an unset one, which the frontend would refuse to read.
*/
Expand Down Expand Up @@ -881,7 +892,8 @@ std::expected<void, Operation::Error> OperationQueue::addDownloadOperation(
auto opts = resolveDownloadOptions(transferOptions, resolvedTimeout);
opts.remotePath = remotePath;
opts.localPath = localPath;
opts.bigFileOptimized = isBigFile;
// The caller's size can be missing, the slow path reports no speed.
opts.bigFileOptimized = isBigFile || result->size >= Constants::bigFileCutOff;
opts.entry = result.value();
opts.createMissingDirectories = createMissingDirectories;
opts.progressCallback = [weak = weak_from_this(), operationId, name = rpcName("onDownloadProgress")](
Expand Down Expand Up @@ -1444,7 +1456,8 @@ std::expected<void, Operation::Error> OperationQueue::addUploadOperation(
auto opts = resolveUploadOptions(transferOptions, resolvedTimeout);
opts.remotePath = remotePath;
opts.localPath = localPath;
opts.bigFileOptimized = isBigFile;
// A dropped or tracked file comes without a size, the slow path reports no speed.
opts.bigFileOptimized = isBigFile || (!isSymlink && localFileSize(localNativePath) >= Constants::bigFileCutOff);
opts.createMissingDirectories = createMissingDirectories;
opts.progressCallback = [weak = weak_from_this(), operationId, name = rpcName("onUploadProgress")](
auto min, auto max, auto current, auto bytesPerSecond
Expand Down
Loading