denull / RemoteTree

Sublime Text 3 plugin for browsing remote file tree via SFTP
23 stars 12 forks source link

No upload on save #13

Open st3ph opened 6 years ago

st3ph commented 6 years ago

First things first, thank you for this plugin, I have been waiting for something like this since a long time Unfortunately I can set a remote server, browser and open files but when I save them they aren't upload to the server.

Sublime version: 3.1.1 Build 3176

Let me know if you need more informations

dmarienko commented 6 years ago

Yeah, I see same situation: when I save file it isn't uploaded back to server. Nothing is logged in console. PS: I'm using Windows10 / ST3 3.1.1, b.3176

atarx commented 5 years ago

The same here.

But I think that the secret is this: This Sublime Text 3 plugin allows you to browse directories on remote servers without need to download the whole file structure.

BROWSE is the magical word.

gwijnja commented 5 years ago

BROWSE is the magical word.

Sure, but the website also says:

Each local file under "local_path" on save will be uploaded back to the server.

It's not just for browsing. It should save the file.

So I did a little debugging by adding some print's to the _on_post_saveasync function in remote-tree.py. And it turns out that the prefix you configure in the RemoteTree settings is wrong. By default, this is set to: "local_path": "~/Sites/" This probably works on Linux, but not on Windows. The local path is expanded to your user directory, for example in my case it becomes: C:\Users\gwijnja/Sites/ Note the mixed backslashes (Unix-style) and forward slashes (Windows-style) in the same path. And then the function checks whether the filename of the file you are saving (for example C:\Users\gwijnja\Sites\\pj.txt) starts with C:\Users\gwijnja/Sites/. It doesn't, so it will not even attempt to save the file remotely. (If the filename does not start with the local path prefix, then it assumes the file does not originate from the remote server.)

A solution is to change your RemoteTree configuration's "local_path": "~/Sites/" to "local_path": "~\\Sites\\" (yes, with double slashes) and also apply the fix from this other thread: https://github.com/deNULL/RemoteTree/issues/14

You may need to restart Sublime, I'm not sure. But then it will work.

xtrinch commented 5 years ago

Thanks, @gwijnja, that works

mercurykd commented 5 years ago

BROWSE is the magical word.

Sure, but the website also says:

Each local file under "local_path" on save will be uploaded back to the server.

It's not just for browsing. It should save the file.

So I did a little debugging by adding some print's to the _on_post_saveasync function in remote-tree.py. And it turns out that the prefix you configure in the RemoteTree settings is wrong. By default, this is set to: "local_path": "~/Sites/" This probably works on Linux, but not on Windows. The local path is expanded to your user directory, for example in my case it becomes: C:\Users\gwijnja/Sites/ Note the mixed backslashes (Unix-style) and forward slashes (Windows-style) in the same path. And then the function checks whether the filename of the file you are saving (for example C:\Users\gwijnja\Sites\\pj.txt) starts with C:\Users\gwijnja/Sites/. It doesn't, so it will not even attempt to save the file remotely. (If the filename does not start with the local path prefix, then it assumes the file does not originate from the remote server.)

A solution is to change your RemoteTree configuration's "local_path": "~/Sites/" to "local_path": "~\\Sites\\" (yes, with double slashes) and also apply the fix from this other thread: #14

You may need to restart Sublime, I'm not sure. But then it will work.

or "local_path": "C:/Sites/", and in remote-tree.py:

def on_post_save_async(self, view):
        global servers
        fname = view.file_name().replace('\\', '/')
        if not fname:
            return