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

Updating when nothing has changed #754

Closed
hmmChase opened this issue Jan 20, 2019 · 13 comments
Closed

Updating when nothing has changed #754

hmmChase opened this issue Jan 20, 2019 · 13 comments

Comments

@hmmChase
Copy link

🐛 Describe the bug
When you change a value of a setting property that has // @sync-ignore on it, it will still update. So if you do it a lot, you end up with a gist history like this...

`@userName userName revised this gist 12 minutes ago. 1 changed file with 1 addition and 1 deletion.

2 cloudSettings
@@ -1 +1 @@
{"lastUpload":"2019-01-20T23:35:15.940Z","extensionVersion":"v3.2.4"} {"lastUpload":"2019-01-20T23:35:31.712Z","extensionVersion":"v3.2.4"}
@userName userName revised this gist 12 minutes ago. 1 changed file with 1 addition and 1 deletion.

2 cloudSettings
@@ -1 +1 @@
{"lastUpload":"2019-01-20T23:35:04.064Z","extensionVersion":"v3.2.4"} {"lastUpload":"2019-01-20T23:35:15.940Z","extensionVersion":"v3.2.4"}
@userName userName revised this gist 12 minutes ago. 1 changed file with 1 addition and 1 deletion.

2 cloudSettings
@@ -1 +1 @@
{"lastUpload":"2019-01-20T23:35:00.152Z","extensionVersion":"v3.2.4"} {"lastUpload":"2019-01-20T23:35:04.064Z","extensionVersion":"v3.2.4"}
@userName userName revised this gist 12 minutes ago. 1 changed file with 1 addition and 1 deletion.

2 cloudSettings
@@ -1 +1 @@
{"lastUpload":"2019-01-20T23:34:56.838Z","extensionVersion":"v3.2.4"} {"lastUpload":"2019-01-20T23:35:00.152Z","extensionVersion":"v3.2.4"}
@userName userName revised this gist 12 minutes ago. 1 changed file with 1 addition and 1 deletion.
`

The only change that is being uploaded is a change to date/time. I change my ignored setting dozens of times per day, so my Gist log looks crazy. It's a lot of unnecessary uploading. Could you make it so the anything with a // @sync-ignore doesn't trigger an upload? Thank you very much for this awesome tool.

@shanalikhan
Copy link
Owner

Could you make it so the anything with a // @sync-ignore doesn't trigger an upload?

@ioprotium how about stopping on-change trigger for upload on the change of value @sync-ignore ?

As at the end @sync-ignore value wont upload on gist, its better to stop the trigger on the change or addition of @sync-ignore.

What do you think about it ?

@protiumx
Copy link
Contributor

@shanalikhan Yes, we should make a diff and determine whether the changes should be upload. Tomorrow I will look at this one!

@shanalikhan
Copy link
Owner

@ioprotium
That would be great. Looking forward

@protiumx
Copy link
Contributor

protiumx commented Feb 18, 2019

@shanalikhan we have a problem. VS doesn't supply a way to determine what changed in the file. The watcher is triggered only after the file was changed and saved to the system. So, if we need to determine if the changes must be upload we should compare the local file against the gist. This implies download the entire gist. Am I right?

@shanalikhan
Copy link
Owner

Yes, you are right.
We need to extract the settings.json file only from the gist and compare it.

@protiumx
Copy link
Contributor

I've got another idea. Every time the upload action is triggered we can persist a copy without all the @ignore pragmas, then we use it to compare changes in the next trigger. If other changes rather than @ignore were done, the file is uploaded and a new copy is generated.

What do you think? Could you provide me the needed functions to create and read this "clean" settings file?

@shanalikhan
Copy link
Owner

we can persist a copy

Where you will persist the copy ? Do you have any ideas about that or you are looking to save the copy in User folder.

needed functions to create and read

If you look here, I'm reading the files using this function and saving in a gist.

https://github.com/shanalikhan/code-settings-sync/blob/master/src/sync.ts#L159

Here is the change detection event that will be hit on changing the settings.json file

https://github.com/shanalikhan/code-settings-sync/blob/master/src/commons.ts#L138

@protiumx
Copy link
Contributor

protiumx commented Feb 25, 2019

Where you will persist the copy ? Do you have any ideas about that or you are looking to save the copy in User folder.

Tell me some folder that is isolated or it will not generate side effects and it should be always available for the extension (maybe created after installation, or the extension folder itself)

@shanalikhan
Copy link
Owner

https://code.visualstudio.com/api/references/vscode-api#ExtensionContext

See here, you can persist the data in states provided by visual studio code api and read to compare.

@shanalikhan
Copy link
Owner

@ioprotium any update ? When you be able to complete ?

@Revolution1
Copy link

same issue here. any update?

@jwmann
Copy link

jwmann commented Apr 17, 2019

Having the same issue as #553

@protiumx protiumx mentioned this issue May 2, 2019
@protiumx
Copy link
Contributor

protiumx commented May 2, 2019

Hi, sorry for the long delay. I've just sent the PR #867

This was referenced May 2, 2019
@shanalikhan shanalikhan added this to the v3.3.0 milestone May 6, 2019
@shanalikhan shanalikhan modified the milestones: v3.3.0, Backlog Jun 6, 2019
@shanalikhan shanalikhan modified the milestones: Backlog, v3.3.0 Jun 24, 2019
shanalikhan pushed a commit that referenced this issue Jun 24, 2019
* Fix #754

The pragma util keeps a copy of the settings that are upload to the
gist. The file is located at <context.globalStoragePath>/settings.sync.

If the content to be upload doesn't deffer from the local content after
taking out the @sync-ignore, the file wont be uploaded.

* Fix #754: Sync object

Checks the global storage path at constructor.
Checks if the content of the setting file should be uploaded.

* Update tests

* Fix #865

* Fix broken tests

* Fixing Octokit wrong type for GistsResponse

'file' field is wrong with static data.

* Defining PragmaUtil behavior

Pragma util should only parse string content, checking each line for pragma statements.

* Updating test for Pragma definition

* Sync: don't upload is not necessary

As the extension gets the entire gists before commiting an upload, we can check each file of the gists against our local files in order to determine if the content has changed.

There is no need to keel a local copy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants