Trouble Getting cloud.sync working as I expect

Discussion and help for Easy Save 3
Post Reply
mtdev
Posts: 4
Joined: Wed Nov 01, 2023 2:38 am

Trouble Getting cloud.sync working as I expect

Post 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!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Trouble Getting cloud.sync working as I expect

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
mtdev
Posts: 4
Joined: Wed Nov 01, 2023 2:38 am

Re: Trouble Getting cloud.sync working as I expect

Post 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);
    }
}
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Trouble Getting cloud.sync working as I expect

Post 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
Attachments
Capture.PNG
Capture.PNG (13.47 KiB) Viewed 2216 times
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
mtdev
Posts: 4
Joined: Wed Nov 01, 2023 2:38 am

Re: Trouble Getting cloud.sync working as I expect

Post 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";
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Trouble Getting cloud.sync working as I expect

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
mtdev
Posts: 4
Joined: Wed Nov 01, 2023 2:38 am

Re: Trouble Getting cloud.sync working as I expect

Post 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!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Trouble Getting cloud.sync working as I expect

Post by Joel »

Glad that's all working for you now :)

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply