Skip to content

Commit 6bf34c8

Browse files
authored
Merge branch 'Pennyw0rth:main' into rdp-nego
2 parents 2ec020a + 08b43bf commit 6bf34c8

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

nxc/database.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import configparser
22
import ipaddress
3+
import platform
34
import shutil
45
import sys
56
from os import mkdir
@@ -170,11 +171,23 @@ def reflect_table(self, table):
170171

171172
return reflected_table
172173
except (NoInspectionAvailable, NoSuchTableError, ValueError) as e:
174+
commands_platform = {
175+
"Windows": [
176+
f"cmd /c copy {self.db_path} %USERPROFILE%\\nxc_{self.protocol.lower()}.bak",
177+
f"del {self.db_path}"
178+
],
179+
"Linux": [
180+
f"cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak",
181+
f"rm -f {self.db_path}"
182+
]
183+
}
184+
copy_command = commands_platform["Windows"][0] if platform.system() == "Windows" else commands_platform["Linux"][0]
185+
delete_command = commands_platform["Windows"][1] if platform.system() == "Windows" else commands_platform["Linux"][1]
173186
nxc_logger.fail(f"Schema mismatch detected for table '{table.__tablename__}' in protocol '{self.protocol}'")
174187
nxc_logger.debug(e)
175188
nxc_logger.fail("This is probably because a newer version of nxc is being run on an old DB schema.")
176-
nxc_logger.fail(f"Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)")
177-
nxc_logger.fail(f"Then remove the {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB")
189+
nxc_logger.fail(f"Optionally save the old DB data (`{copy_command}`)")
190+
nxc_logger.fail(f"Then remove the {self.protocol} DB (`{delete_command}`) and run nxc to initialize the new DB")
178191
sys.exit()
179192

180193
def shutdown_db(self):

nxc/protocols/ftp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def list_directory_full(self):
121121
# ftplib's "dir" prints directly to stdout, and "nlst" only returns the folder name, not full details
122122
files = []
123123
try:
124-
self.conn.retrlines("LIST", callback=files.append)
124+
self.conn.retrlines("LIST -a", callback=files.append)
125125
except error_perm as error_message:
126126
self.logger.fail(f"Failed to list directory. Response: ({error_message})")
127127
self.conn.close()

nxc/protocols/ftp/proto_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def proto_args(parser, parents):
66
ftp_parser.add_argument("--port", type=int, default=21, help="FTP port")
77

88
cgroup = ftp_parser.add_argument_group("File Operations")
9-
cgroup.add_argument("--ls", metavar="DIRECTORY", nargs="?", const=".", help="List files in the directory")
9+
cgroup.add_argument("--ls", metavar="DIRECTORY", nargs="?", const=".", help="List all files (including hidden) in the directory")
1010
cgroup.add_argument("--get", metavar="FILE", help="Download a file")
1111
cgroup.add_argument("--put", metavar=("LOCAL_FILE", "REMOTE_FILE"), nargs=2, help="Upload a file")
1212
return parser

0 commit comments

Comments
 (0)