fix list files and dirs bug (#4826)

* fix list files and dirs bug

* test case

* recording
This commit is contained in:
JinmingHu 2023-07-31 13:19:54 +08:00 committed by GitHub
parent 6ad42e1e40
commit c8693fe8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 2 deletions

View File

@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/storage",
"Tag": "cpp/storage_b920de0000"
"Tag": "cpp/storage_02a857d53e"
}

View File

@ -8,6 +8,8 @@
### Bugs Fixed
- Fixed a bug where `ShareDirectoryClient::ListFilesAndDirectories` only returns the first page without ContinuationToken, even if there are more pages.
### Other Changes
## 12.6.0 (2023-07-11)

View File

@ -550,7 +550,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
pagedResponse.m_shareDirectoryClient = std::make_shared<ShareDirectoryClient>(*this);
pagedResponse.m_operationOptions = options;
pagedResponse.CurrentPageToken = options.ContinuationToken.ValueOr(std::string());
pagedResponse.NextPageToken = response.Value.Marker;
pagedResponse.NextPageToken = response.Value.NextMarker;
pagedResponse.RawResponse = std::move(response.RawResponse);
return pagedResponse;

View File

@ -577,6 +577,44 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NE(smbProperties2.ChangedOn.Value(), smbProperties.ChangedOn.Value());
}
TEST_F(FileShareDirectoryClientTest, ListFilesAndDirectoriesMultiPageTest)
{
auto dirClient = m_shareClient->GetRootDirectoryClient().GetSubdirectoryClient(RandomString());
dirClient.Create();
std::set<std::string> nameSet;
for (size_t i = 0; i < 5; ++i)
{
auto dirname = RandomString();
auto subdirClient = dirClient.GetSubdirectoryClient(dirname);
subdirClient.Create();
auto filename = RandomString();
auto fileClient = dirClient.GetFileClient(filename);
fileClient.Create(1024);
nameSet.insert(dirname);
nameSet.insert(filename);
}
Files::Shares::ListFilesAndDirectoriesOptions listOptions;
listOptions.PageSizeHint = 3;
std::set<std::string> listedNameSet;
int numPages = 0;
for (auto page = dirClient.ListFilesAndDirectories(listOptions); page.HasPage();
page.MoveToNextPage())
{
++numPages;
for (const auto& i : page.Directories)
{
listedNameSet.insert(i.Name);
}
for (const auto& i : page.Files)
{
listedNameSet.insert(i.Name);
}
}
EXPECT_EQ(nameSet, listedNameSet);
EXPECT_GT(numPages, 1);
}
TEST_F(FileShareDirectoryClientTest, ListFilesAndDirectoriesSinglePageTest)
{
// Setup