How to save AItems in OnGetFolderList event?

Hi,

I hope you can help me. How can I save the TCloudItem information of a folder in GetFolderList()?

Currently I get the the folder structure in GetFolderList() and I save the AItems in my var called existingFilesList.

existingFilesList := AItems;

In next step I walk through the list to find a special folder, lets call "Photos". I found it and save it in my var ciPhotoFolder which is a TTMSFNCCloudItem.

  ciPhotoFolder := NIL;

  if existingFilesList <> NIL then
    for i := 0 to existingFilesList.Count-1 do
    begin
      if (existingFilesList.Items[i].FileName = cFolderPhotoSDCard)
      and (existingFilesList.Items[i].ItemType = ciFolder) then
      begin
        if TMSFNCCloudStorageServices.Service = cssDropbox then
          ciPhotoFolder.Assign(existingFilesList.Items[i] as TTMSFNCCloudDropboxItem );

        if TMSFNCCloudStorageServices.Service = cssMicrosoftOneDrive then
          ciPhotoFolder.Assign(existingFilesList.Items[i] as TTMSFNCCloudMicrosoftOneDriveItem );

        if TMSFNCCloudStorageServices.Service = cssGoogleDrive then
          ciPhotoFolder.Assign(existingFilesList.Items[i] as TTMSFNCCloudGoogleDriveItem );

        break;
      end;
    end;

log.d(ciPhotoFolder.Filename) shows me the correct foldername.

Next I want to know the files from this folder. So I call GetFolderListHierarchical(ciPhotoFolder);

And now comes the problem:
In GetFolderList() my variable ciPhotoFolder.Filename is a file from this folder. That means the variable was overwritten. But why? I did assign the folder item to ciPhotoFolder.

What is the best way to save AItems?
existingFilesList.Assign(AItems); doesn't work.

We are not aware of an issue with this technique. Can you please provide a ready to run sample project that demonstrates the issue so I can further investigate this?

A few minutes ago I've send to you the sample project.

I have not received a sample project.
You can use help@tmssoftware.com or a private message on the support center to send sample projects.
Please make sure to not include executable files.

You're right. I answered to the mail from your Support Center and this was a temporary mail address.
I did send it again to the right address.

Hi,

Can you please make the following changes in your code?

  • Declare existingFilesList as TTMSFNCCloudGoogleDriveItems
  • First create the existingFilesList object and then assign it with the AItems object
  • Remember to free the existingFilesList object afterwards

Example:
existingFilesList : TTMSFNCCloudGoogleDriveItems;

if not Assigned(existingFilesList) then
existingFilesList := TTMSFNCCloudGoogleDriveItems.Create(nil, nil);
existingFilesList.Clear;
existingFilesList.Assign(AItems);

Hi, thanks for the hint about the object creation. I did make a small improvement, because at the beginning I don't know, whiche Cloud the user uses.

var
existingFilesList : TTMSFNCCloudItems;
// ...
if not Assigned(existingFilesList) then
begin
if TMSFNCCloudStorageServices1.Service = cssDropbox then
existingFilesList := TTMSFNCCloudDropboxItems.Create(nil, nil);
if TMSFNCCloudStorageServices1.Service = cssMicrosoftOneDrive then
existingFilesList := TTMSFNCCloudMicrosoftOneDriveItems.Create(nil, nil);
if TMSFNCCloudStorageServices1.Service = cssGoogleDrive then
existingFilesList := TTMSFNCCloudGoogleDriveItems.Create(nil, nil);
end;
existingFilesList.Clear;
existingFilesList.Assign(AItems);

And it seems to work. Thanks.

PS: When did you plan to make the CloudItem.ParentFolder working?

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.

We are not aware of any issues with the ParentFolder property.
Can you please explain the issue?