diff --git a/copyparty/sftpd.py b/copyparty/sftpd.py index 17c6993c..aff5c358 100644 --- a/copyparty/sftpd.py +++ b/copyparty/sftpd.py @@ -30,6 +30,10 @@ from .util import ( Daemon, ODict, Pebkac, + exclude_dotfiles, + exclude_dotfiles_ls, + exclude_dothidden, + exclude_dothidden_ls, ipnorm, min_ex, read_utf8, @@ -401,21 +405,27 @@ class SFTP_Srv(paramiko.SFTPServerInterface): self.log("ls(%s): vfs-vols; |%d|" % (path, len(ret))) return ret - _, vfs_ls, vfs_virt = vn.ls( + fsroot, vfs_ls, vfs_virt = vn.ls( rem, self.uname, not self.args.no_scandir, [[True, False], [False, True]], throw=True, ) + vnames = list(vfs_virt) + if self.uname not in vn.axs.udot: + if "dothidden" in vn.flags and ".hidden" in [x[0] for x in vfs_ls]: + vfs_ls = exclude_dothidden_ls(vfs_ls, fsroot) + vnames = exclude_dothidden(vnames, fsroot) + else: + vfs_ls = exclude_dotfiles_ls(vfs_ls) + vnames = exclude_dotfiles(vnames) ret = [SATTR.from_stat(x[1], filename=x[0]) for x in vfs_ls] for zs, vn2 in vfs_virt.items(): - if not vn2.realpath: + if not vn2.realpath or zs not in vnames: continue st = bos.stat(vn2.realpath) ret.append(SATTR.from_stat(st, filename=zs)) - if self.uname not in vn.axs.udot: - ret = [x for x in ret if not x.filename.split("/")[-1].startswith(".")] ret.sort(key=lambda x: x.filename) self.log("ls(%s): |%d|" % (path, len(ret))) return ret