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

Provide Support for WebDAV #3

Closed
manuth opened this issue Jan 14, 2022 · 26 comments
Closed

Provide Support for WebDAV #3

manuth opened this issue Jan 14, 2022 · 26 comments

Comments

@manuth
Copy link
Contributor

manuth commented Jan 14, 2022

Is WebDAV as a repository backend supported?
I'd love to have my settings uploaded to my Nextcloud automatically.

Thanks a ton for your great work - it's awesome to finally have a competitor to VSCode's Settings Sync!

@daiyam
Copy link
Member

daiyam commented Jan 14, 2022

That should be doable with the help of https://github.com/perry-mitchell/webdav-fs and some files sync.

@daiyam
Copy link
Member

daiyam commented Jan 14, 2022

@manuth Can you try this version sync-settings-0.6.2.vsix.zip? (remove the .zip to install).
It's including a basic WebDAV support.

Here my test settings:

hostname: ""
profile: main
repository:
  type: webdav
  url: http://localhost:9988/webdav/server
  username: webdav-user
  password: pa$$w0rd!

All the options from https://github.com/perry-mitchell/webdav-client#client-configuration can be used.

@manuth
Copy link
Contributor Author

manuth commented Jan 14, 2022

Wow, that was fast!
Sadly, it doesn't seem to work. I get following error:

[error] Error: certificate has expired

In spite of this error message, my WebDAV's certificate is valid:
https://cloud.nuth.ch/

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

Not sure what is the issue... When using your url with my fake user, I get Error: Invalid response: 405 Not Allowed which means, I think, that the SSL handshake was successful.

Here a new version sync-settings-0.6.2.vsix.zip which add the support for the http(s)Agent option.

Maybe try:

hostname: ""
profile: main
repository:
  type: webdav
  url: https://cloud.nuth.ch/
  username: <your username>
  password: <your password>
  agent:
    rejectUnauthorized: false

The agent's options are from https://nodejs.org/api/https.html#new-agentoptions or https://nodejs.org/api/tls.html#tlsconnectoptions-callback

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

From the NextCloud's doc, the WebDAV url seems to be something like https://cloud.nuth.ch/remote.php/dav/files/USERNAME/.

@manuth
Copy link
Contributor Author

manuth commented Jan 15, 2022

From the NextCloud's doc, the WebDAV url seems to be something like https://cloud.nuth.ch/remote.php/dav/files/USERNAME/.

Yeah, that's correct - this is what my URL looks like.

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

Wait!

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

The url should include the path of directory where your want to sync the settings.

@manuth
Copy link
Contributor Author

manuth commented Jan 15, 2022

It does so. I'll try the new version tomorrow.
Thank you very much for taking care 😄

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

I've just reread my code to see I don't abusively delete files from the WebDAV. Well, right now, it's doesn't remove any files... just creates new ones. Way too basic, I need to improve that!

But the question is should the url should include the "working" directory? Or have a separate "directory" option?
I'm worried that using unified url (server+directory) could lead to some unfortunate file deletions... Having a separate non-empty "directory" would force to user to put the correct path.

Before working with WebDAV, I will add a check to see if the directory is empty or if it contains the expected files/directories. If not, the extension won't do anything...

edit: With the check, the url can be unified. Good night... 😴

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

Here the latest version: sync-settings-0.6.2.vsix.zip

I've added a validation of the working directory. If it's empty, the extension create a file .vsx. If not, it matches the content of the file .vsx and if it doesn't match, then it generates an error.
For the upload, it firstly uploads the profiles into the temporary directory .profiles. When complete, it deletes the old profiles directory and rename .profiles to profiles. This way, I ensure the integrity of the profiles and delete only what necessary.

Tell me if it's working for you. I would then release it.
By the way, the changes are in the branch feat-webdav.

@manuth
Copy link
Contributor Author

manuth commented Jan 15, 2022

Okay, this is different - I'm getting following error now:

[error] Error: certificate has expired
[error] Error: The repository is not initialized

No idea what it's complaining about my certificate for.

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

@manuth Is there a way for me to test with your server?

@manuth
Copy link
Contributor Author

manuth commented Jan 15, 2022

Sure - I created a temporary account. However - I'll have to delete said account once we're done with testing.
I sent you an e-mail containing the credentials.

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

Have you send it to daiyam@zokugun.org?

@manuth
Copy link
Contributor Author

manuth commented Jan 15, 2022

Sorry - I had some trouble sending the e-mail.
It's sent now.

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

Ya, I'm getting the error when running the extension. But the connection is fine when running with a test case...

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

I'm getting the error:

[Extension Host] Error: certificate has expired
	at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)
	at TLSSocket.emit (events.js:315:20)
	at TLSSocket._finishInit (_tls_wrap.js:932:8)
	at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12)

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

It seems to be bug with Electron (cf electron/electron#31212).

@manuth
Copy link
Contributor Author

manuth commented Jan 15, 2022

Never would I have guessed that out of all possibilities it's electron causing the issue 😅
Anyways - this sure means it's working in theory (that is... until the issue in electron is fixed).

That's awesome - thanks for your effort 😄

@daiyam
Copy link
Member

daiyam commented Jan 15, 2022

Here the latest version sync-settings-0.6.2.vsix.zip

I've added the option ignoreTLSErrors to bypass that error.

Here the config used successfully:

repository:
  type: webdav
  url: https://cloud.nuth.ch/remote.php/dav/files/sync-settings/Apps/vscode-settings/
  username:
  password:
  ignoreTLSErrors: true

Feel free to clean up your WebDAV as you want 😉

@manuth
Copy link
Contributor Author

manuth commented Jan 15, 2022

That's awesome! 😄
I can confirm it's working as expected now

Thanks für taking care about it!

@daiyam
Copy link
Member

daiyam commented Jan 17, 2022

@manuth Do you have any issue? If not, I will release the new version.

@manuth
Copy link
Contributor Author

manuth commented Jan 17, 2022

I have no issue - you might consider to wait until the electron error is fixed, tho (?)

Apart from that it'd be great to have this released 😄

@daiyam
Copy link
Member

daiyam commented Jan 17, 2022

I've added to the doc: https://github.com/zokugun/vscode-sync-settings/blob/feat-webdav/docs/webdav.md#common-errors
So I think it would be fine.

@daiyam
Copy link
Member

daiyam commented Jan 17, 2022

I've published the new version.

@daiyam daiyam closed this as completed Jan 17, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants