Skip to content

Commit

Permalink
clang-tidy, bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekazakov committed Feb 8, 2025
1 parent 29fc7b2 commit 12eac2d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
6 changes: 4 additions & 2 deletions Source/Operations/source/Copying/CopyingJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,8 +1624,10 @@ CopyingJob::StepResult CopyingJob::CopyVFSFileToVFSFile(VFSHost &_src_vfs,
// we need to revert what we've done
dst_file->Close();
dst_file.reset();
if( do_unlink_on_stop )
m_DestinationHost->Unlink(_dst_path, nullptr);
if( do_unlink_on_stop ) {
// TODO: we do why ignore the result of this unlinking?
std::ignore = m_DestinationHost->Unlink(_dst_path);
}
}
});

Expand Down
3 changes: 3 additions & 0 deletions Source/VFS/source/NetFTP/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ std::expected<void, Error> FTPHost::Unlink(std::string_view _path,
m_Cache->CommitUnlink(_path);

CommitIOInstanceAtDir(parent_path, std::move(curl));

if( curl_res == CURLE_OK )
return {};

return std::unexpected(VFSError::ToError(CURLErrorToVFSError(curl_res)));
}
Expand Down
30 changes: 15 additions & 15 deletions Source/VFS/tests/VFSDropbox_IT.mm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
const auto to_upload = "Hello, world!"s;
const auto filepath = "/FolderToModify/test.txt";
const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

std::shared_ptr<VFSFile> file;
REQUIRE(host->CreateFile(filepath, file) == VFSError::Ok);
Expand All @@ -220,7 +220,7 @@
REQUIRE(equal(uploaded->begin(), uploaded->end(), to_upload.begin()));
REQUIRE(file->Close() == VFSError::Ok);

host->Unlink(filepath);
std::ignore = host->Unlink(filepath);
}

TEST_CASE(PREFIX "upload with invalid name")
Expand All @@ -244,7 +244,7 @@
const auto to_upload = "Hello, world!"s;
const auto filepath = "/FolderToModify/test.txt";
const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

std::shared_ptr<VFSFile> file;
REQUIRE(host->CreateFile(filepath, file) == VFSError::Ok);
Expand All @@ -267,15 +267,15 @@
REQUIRE(std::equal(uploaded->begin(), uploaded->end(), to_upload_new.begin()));
REQUIRE(file->Close() == VFSError::Ok);

host->Unlink(filepath);
std::ignore = host->Unlink(filepath);
}

TEST_CASE(PREFIX "UnfinishedUpload")
{
const auto to_upload = "Hello, world!"s;
const auto filepath = "/FolderToModify/test.txt";
const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

std::shared_ptr<VFSFile> file;
REQUIRE(host->CreateFile(filepath, file) == VFSError::Ok);
Expand All @@ -292,7 +292,7 @@
{
const auto filepath = "/FolderToModify/zero.txt";
const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

std::shared_ptr<VFSFile> file;
REQUIRE(host->CreateFile(filepath, file) == VFSError::Ok);
Expand All @@ -304,15 +304,15 @@
VFSStat stat;
REQUIRE(host->Stat(filepath, stat, 0) == VFSError::Ok);
REQUIRE(stat.size == 0);
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);
}

TEST_CASE(PREFIX "decent sized upload")
{
const auto length = 5 * 1024 * 1024; // 5Mb upload / download
const auto filepath = "/FolderToModify/SomeRubbish.bin";
const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

std::shared_ptr<VFSFile> file;
REQUIRE(host->CreateFile(filepath, file) == VFSError::Ok);
Expand All @@ -331,15 +331,15 @@
REQUIRE(equal(uploaded->begin(), uploaded->end(), to_upload.begin()));
REQUIRE(file->Close() == VFSError::Ok);

host->Unlink(filepath);
std::ignore = host->Unlink(filepath);
}

TEST_CASE(PREFIX "two-chunk upload")
{
const auto length = 17 * 1024 * 1024; // 17MB upload / download
const auto filepath = "/FolderToModify/SomeBigRubbish.bin";
const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

std::shared_ptr<VFSFile> file;
REQUIRE(host->CreateFile(filepath, file) == VFSError::Ok);
Expand All @@ -359,7 +359,7 @@
REQUIRE(std::equal(uploaded->begin(), uploaded->end(), to_upload.begin()));
REQUIRE(file->Close() == VFSError::Ok);

host->Unlink(filepath);
std::ignore = host->Unlink(filepath);
}

TEST_CASE(PREFIX "multi-chunks upload")
Expand All @@ -368,7 +368,7 @@

const auto filepath = "/FolderToModify/SomeBigRubbish.bin";
const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

std::shared_ptr<VFSFile> file;
REQUIRE(host->CreateFile(filepath, file) == VFSError::Ok);
Expand All @@ -388,7 +388,7 @@
REQUIRE(equal(uploaded->begin(), uploaded->end(), to_upload.begin()));
REQUIRE(file->Close() == VFSError::Ok);

host->Unlink(filepath);
std::ignore = host->Unlink(filepath);
}

TEST_CASE(PREFIX "upload edge cases")
Expand All @@ -399,7 +399,7 @@
const auto filepath = "/FolderToModify/SomeBigRubbish.bin";

const std::shared_ptr<VFSHost> host = Spawn();
host->Unlink(filepath);
std::ignore = host->Unlink(filepath);

for( auto length : lengths ) {
std::shared_ptr<VFSFile> file;
Expand All @@ -420,7 +420,7 @@
REQUIRE(equal(uploaded->begin(), uploaded->end(), to_upload.begin()));
REQUIRE(file->Close() == VFSError::Ok);

host->Unlink(filepath);
std::ignore = host->Unlink(filepath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/VFS/tests/VFSFTP_IT.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// if there's a trash from previous runs - remove it
if( host->Stat(fn2, stat, 0, nullptr) == 0 )
REQUIRE(host->Unlink(fn2, nullptr));
REQUIRE(host->Unlink(fn2));

// copy file to the remote server
REQUIRE(VFSEasyCopyFile(fn1, TestEnv().vfs_native, fn2, host) == 0);
Expand All @@ -44,7 +44,7 @@
REQUIRE(host->Stat(fn2, stat, 0, nullptr) == 0);

// delete it
REQUIRE(host->Unlink(fn2, nullptr));
REQUIRE(host->Unlink(fn2));
REQUIRE(!host->Unlink("/Public/!FilesTesting/wf8g2398fg239f6g23976fg79gads")); // also check deleting wrong entry

// check that it is no longer available in stat cache
Expand Down

0 comments on commit 12eac2d

Please sign in to comment.