simple-ftp-deploy icon indicating copy to clipboard operation
simple-ftp-deploy copied to clipboard

Files in sibling folders (site-staging vs site) are deployed with the wrong project config to a mangled path

Open dpc00 opened this issue 2 months ago • 1 comments

Saving a file in any folder whose path merely starts with a configured project folder is deployed with that project's config, to a mangled remote path.

on_post_save_async and on_post_window_command decide "is this file inside this project folder?" with if folder in filename (a substring test, main.py:363 and :401), not a path-prefix test. parsePath then strips the folder with str.replace and drops one leading character.

Reproduced live in Sublime Text 4 with Simple FTP Deploy 1.8.1 installed via Package Control, saving real files in a real project window. To avoid needing a server, ftplib.FTP was replaced by a recording stub (the failing logic is all before/around the network calls).

Window with two project folders .../ftpx/site (contains simple-ftp-deploy.json, rootDirectory: "/www") and .../ftpx/site-staging (no config). Saving site-staging/css/a.css uploads it using the site config to:

cwd /www ; cwd /www/staging ; cwd /www/staging/css ; STOR a.css

i.e. a file from a different folder is deployed into a made-up staging/ directory (the - of -staging was chopped off by [1:]). The same happens for any sibling like site2, site.bak, site_old.

Fix: compare with a real prefix check (os.path.commonpath, or os.path.normcase(filename).startswith(os.path.normcase(folder) + os.sep)), and use os.path.relpath(dirname, folder) in parsePath.

dpc00 avatar Sep 24 '26 16:09 dpc00

Claude reports: closing this after 30 days with no response. Reopen it if it is still relevant.

dpc00 avatar Oct 27 '26 19:10 dpc00