Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe upload #1026

Merged
merged 3 commits into from
Sep 5, 2019
Merged

Safe upload #1026

merged 3 commits into from
Sep 5, 2019

Conversation

karl-lunarg
Copy link
Contributor

Short description of what this resolves:

Allows uploading settings without forcing when multiple machines are uploading settings.

Example failing scenario:

  • Machine A uploads settings to cloud
  • Machine B downloads these settings
  • Machine B changes settings and uploads them to the cloud
  • Machine A downloads the settings
  • Machine A changes settings and tries to upload them

The last upload attempt fails because A's last upload time is before the cloud's last upload time, even though A downloaded the settings. A forced upload is needed in order to upload the settings. It, therefore, makes sense to compare against the local download time.

Changes proposed in this pull request:

  • Change IsGistNewer to compare the gist upload time to the local download time
  • On an upload, set the local download time to the same upload time
  • Fix bug with the check to see if files have changed. This prevents "empty" uploads when snippet files are present.
  • Fix some status bar message timeouts so that upload canceled messages are visible.

Fixes: #1016

How Has This Been Tested?

  • Tested single machine scenario where a single machine is uploading and downloading settings.
    • Verify download downloads only when needed
    • Verify upload triggers popup when there are no local changes
    • Verify upload is performed when there is a local change
  • Tested failing two-machine scenario noted above
  • All testing accomplished with two Linux machines.

Screenshots (if appropriate):

n/a

Checklist:

  • [x ] I have read the contribution guidelines.
  • My change requires a change to the documentation and GitHub Wiki.
  • I have updated the documentation and Wiki accordingly.

src/sync.ts Outdated Show resolved Hide resolved
Instead of comparing the gist's latestUpload time against the local
latestUpload time, this function should compare the gist time against
the local latestDownload time in order to determine if the cloud
settings are newer than the local settings.

Also, on an upload, set the local latestDownload time to the same
time as the upload since the settings are effectively "downloaded" on
an upload.

This protects against the following scenario:

- Machine A uploads settings to cloud
- Machine B downloads these settings
- Machine B changes settings and uploads them to the cloud
- Machine A downloads the settings
- Machine A changes settings and tries to upload them

The last upload attempt fails because A's last upload time is before
the cloud's last upload time, even though A downloaded the settings.
A forced upload is needed in order to upload the settings.
It therefore makes sense to compare against the local download time.
When checking for the existance of files in the gist, use the
settings file "gistName" to lookup the file in the gist instead of
"fileName" in order to find any files in a subdir.  The gist uses "|"
as a separator in the "gistName" for files in a subdir and so using
a plain filename does not match.

This fixes the case where a user has snippets and does an upload with
no changes to settings or snippets.  The snippets are already up in the
gist.  The code that checks for files that are local and not in the gist
fails to match the fileName to the gistName and incorrectly concludes
that the file is not in the gist.  This causes the upload code to upload
all the files even if there were no changes, resulting in an "empty"
gist revision with only the upload timestamp changed.
@karl-lunarg
Copy link
Contributor Author

Rebased and fixed up the snippet-related commit. Ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants