Page 1 of 1

Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 2:50 am
by mtdev

Code: Select all

using System.Collections;
using Sirenix.OdinInspector;
using UnityEngine;

public class MapSyncer : MonoBehaviour
{
    private ES3Cloud cloud;
    private ES3Settings originalES3Settings;
    private ES3Settings campaignES3Settings;
    private ES3Settings communityES3Settings;
    private ES3Settings testES3Settings;
    private void Awake()
    {
        Debug.Log(Application.persistentDataPath);
        
        originalES3Settings = new ES3Settings();
        originalES3Settings.path = Application.persistentDataPath + "/Maps/Original.zip";  // <-- "works but of course only for me"
        originalES3Settings.location = ES3.Location.File;
        campaignES3Settings = new ES3Settings();
        campaignES3Settings.path = "/Maps/Campaign.zip"; // <-- does not work, would expect it to
        campaignES3Settings.location = ES3.Location.File;
        communityES3Settings = new ES3Settings();
        communityES3Settings.path = "Maps/Community.zip"; // <-- does not work, as expected
        communityES3Settings.location = ES3.Location.File;
    }

    private void Start()
    {
        cloud = new ES3Cloud("the url", "api key");
        StartCoroutine(SyncOriginalMaps());
        StartCoroutine(SyncCampaignMaps());
        StartCoroutine(SyncCommunityMaps());
    }

    [Button] IEnumerator UploadOriginalMaps()
    {
        yield return UploadMapFile(originalES3Settings);
        MapLoader.Instance.UnPackageOriginalMaps();
    }
    IEnumerator UploadMapFile(ES3Settings mapFileSettings)
    {
        yield return StartCoroutine(cloud.UploadFile(mapFileSettings.path));
        if(cloud.isError) Debug.LogError(cloud.error);
    }
    [Button] IEnumerator DownloadOriginalMaps()
    {
        yield return DownloadMapFile(originalES3Settings);
        MapLoader.Instance.UnPackageOriginalMaps();
    }
    IEnumerator DownloadMapFile(ES3Settings mapFileSettings)
    {
        yield return StartCoroutine(cloud.DownloadFile(mapFileSettings.path));
        if(cloud.isError) Debug.LogError(cloud.error);
    }
    [Button] IEnumerator SyncOriginalMaps()
    {
        yield return SyncMapFile(originalES3Settings);
        MapLoader.Instance.UnPackageOriginalMaps();
    }
    [Button] IEnumerator SyncCampaignMaps()
    {
        yield return SyncMapFile(campaignES3Settings);
        MapLoader.Instance.UnPackageCampaignMaps();
    }
    [Button] IEnumerator SyncCommunityMaps()
    {
        yield return SyncMapFile(communityES3Settings);
        MapLoader.Instance.UnPackageCommunityMaps();
    }
    IEnumerator SyncMapFile(ES3Settings mapFileSettings)
    {
        yield return StartCoroutine(cloud.Sync(mapFileSettings.path));
        if(cloud.isError) Debug.LogError(cloud.error);
    }
}
All files are present in the persistent data path however, only the "original.zip" gets synced

Image

Any help is greatly appreciated as I have about 8 hours troubleshooting this :) - Thank you!

Re: Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 9:27 am
by Joel
Hi there,

You're using the same ES3Cloud object to sync all three of your files at the same time. Instead you should use separate ES3Cloud objects for each sync.

All the best,
Joel

Re: Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 2:05 pm
by mtdev
Thank you for the reply. I have cleaned the code up a bit and use a new cloud object per sync request, however, same behavior. Can you take a second look and see if you have any additional ideas?

Code: Select all

public class MapSyncer : MonoBehaviour
{
    private ES3Settings originalES3Settings;
    private ES3Settings campaignES3Settings;
    private ES3Settings communityES3Settings;
    private void Awake()
    {
        originalES3Settings = new ES3Settings();
        originalES3Settings.path = Application.persistentDataPath + "/Maps/Original.zip";  // <-- "works but of course only for me"
        originalES3Settings.location = ES3.Location.File;
        campaignES3Settings = new ES3Settings();
        campaignES3Settings.path = "/Maps/Campaign.zip"; // <-- does not work, would expect it to
        campaignES3Settings.location = ES3.Location.File;
        communityES3Settings = new ES3Settings();
        communityES3Settings.path = "Maps/Community.zip"; // <-- does not work, as expected
        communityES3Settings.location = ES3.Location.File;
    }

    private void Start()
    {
        StartCoroutine(SyncCampaignMaps());
        StartCoroutine(SyncCommunityMaps());
        StartCoroutine(SyncOriginalMaps());
    }

    [Button] IEnumerator SyncOriginalMaps()
    {
        yield return SyncMapFile(originalES3Settings);
        MapLoader.Instance.UnPackageOriginalMaps();
    }
    [Button] IEnumerator SyncCampaignMaps()
    {
        yield return SyncMapFile(campaignES3Settings);
        MapLoader.Instance.UnPackageCampaignMaps();
    }
    [Button] IEnumerator SyncCommunityMaps()
    {
        yield return SyncMapFile(communityES3Settings);
        MapLoader.Instance.UnPackageCommunityMaps();
    }
    IEnumerator SyncMapFile(ES3Settings mapFileSettings)
    {
        ES3Cloud cloud = new ES3Cloud("","");
        yield return StartCoroutine(cloud.Sync(mapFileSettings.path));
        if(cloud.isError) Debug.LogError(cloud.error);
    }
}

Re: Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 2:43 pm
by Joel
Hi there,

When I tried your code both Original.zip and Community.zip uploaded successfully. You might want to double-check that Community.zip exists in the location provided and that it's filename matches exactly.

Note that "/Maps/Campaign.zip" is invalid as paths beginning with a slash are seen as absolute paths (see https://docs.moodkie.com/easy-save-3/es ... locations/).

All the best,
Joel

Re: Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 3:11 pm
by mtdev
Okay, I cleared out the es3cloud table and set the settings paths to what I think we agree should work. The result is no synced files :(
Image
Image

Code: Select all

        
        originalES3Settings.path = "Maps/Original.zip";  
        campaignES3Settings.path = "Maps/Campaign.zip"; 
        communityES3Settings.path = "Maps/Community.zip";

Re: Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 3:27 pm
by Joel
Please could you create a new project with a very simple scene which replicates your issue (ideally pointing to your server) and private message me a link to it so I can see what is happening.

Also just to check, have you changed any of the settings in Tools > Easy Save 3 > Settings?

All the best,
Joel

Re: Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 3:37 pm
by mtdev
:shock:

Happy to report it was the settings. I had totally forgotten about changing them months ago when we were using a different save system. Thank you for the awesome support Joel!

Re: Trouble Getting cloud.sync working as I expect

Posted: Wed Nov 01, 2023 3:43 pm
by Joel
Glad that's all working for you now :)

All the best,
Joel