summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorShyam Sunder <sgsunder1@gmail.com>2019-09-04 17:58:26 -0400
committerShyam Sunder <sgsunder1@gmail.com>2019-09-04 17:58:26 -0400
commit734e28e014ee6b1ac63108043e8487efae81e584 (patch)
tree49fc7ba2eaedc0e54c4faab3182dbb102a543352 /server
parent369ddaf2f86f1a596716012d295910f38f859bcc (diff)
server/tools: better documentation for file rename admin script
Diffstat (limited to 'server')
-rw-r--r--server/config.yaml.dist2
-rwxr-xr-xserver/szuru-admin14
2 files changed, 7 insertions, 9 deletions
diff --git a/server/config.yaml.dist b/server/config.yaml.dist
index 45fbdb5..ff28c6d 100644
--- a/server/config.yaml.dist
+++ b/server/config.yaml.dist
@@ -7,7 +7,7 @@ name: szurubooru
domain: # example: http://example.com
# user agent name used to download files from the web on behalf of the api users
user_agent:
-# used to salt the users' password hashes
+# used to salt the users' password hashes and generate filenames for static content
secret: change
# required for running the test suite
test_database: 'sqlite:///:memory:'
diff --git a/server/szuru-admin b/server/szuru-admin
index 429dc83..6433fde 100755
--- a/server/szuru-admin
+++ b/server/szuru-admin
@@ -61,18 +61,16 @@ def reset_filenames() -> None:
def convert_to_new_filename(old_name: str) -> str:
matches = regex.match(old_name)
if not matches:
- raise ValueError('Not a valid filename')
+ return None
post_id = int(matches.group(1))
post_ext = matches.group(2)
return '%d_%s.%s' % \
(post_id, postfuncs.get_post_security_hash(post_id), post_ext)
def rename_in_dir(dir: str) -> None:
- for file in os.listdir(config.config['data_dir'] + dir):
- try:
- old_path = file
- new_path = convert_to_new_filename(file)
- except ValueError:
+ for old_path in os.listdir(config.config['data_dir'] + dir):
+ new_path = convert_to_new_filename(old_path)
+ if not new_path:
continue
if old_path != new_path:
print('%s -> %s' % (dir + old_path, dir + new_path))
@@ -95,8 +93,8 @@ def main() -> None:
help='check the audio flags of all posts, '
'noting discrepancies, without modifying posts')
parser.add_argument('--reset-filenames', action='store_true',
- help='reset the content and thumbnail filenames'
- 'caused by a lost/changed secret key')
+ help='reset and rename the content and thumbnail '
+ 'filenames in case of a lost/changed secret key')
command = parser_top.parse_args()
try: