Fix message-file naming; add .server to channel-list

This commit is contained in:
Jaidyn Ann 2023-06-06 11:32:04 -05:00
parent 5801f14046
commit 5248c4b32d

View File

@ -26,6 +26,7 @@
channel-messages-by-date channel-messages-by-date* channel-messages-by-date-range channel-messages-by-date channel-messages-by-date* channel-messages-by-date-range
) )
(import scheme (import scheme
(chicken file) (chicken file posix) (chicken pathname) (chicken port) (chicken file) (chicken file posix) (chicken pathname) (chicken port)
(chicken io) (chicken random) (chicken string) (chicken io) (chicken random) (chicken string)
@ -39,7 +40,7 @@
;; Lists all currently-joined channels. ;; Lists all currently-joined channels.
(define (channels root) (define (channels root)
(directory root)) (append (directory root) '(".server")))
;; Creates a channel's file hierarchy; safe to run, even if the channel ;; Creates a channel's file hierarchy; safe to run, even if the channel
@ -367,17 +368,20 @@
;; a number to the end of the name, as necessary. ;; a number to the end of the name, as necessary.
(define (directory-unique-file directory name #!optional (suffix "")) (define (directory-unique-file directory name #!optional (suffix ""))
(let* ([leaf (let* ([leaf
(string-append name suffix)] (string-append name (if (not (string-null? suffix)) "." "")
suffix)]
[path [path
(subpath directory leaf)]) (subpath directory leaf)])
(if (file-exists? path) (if (file-exists? path)
(directory-unique-file (directory-unique-file
directory directory
leaf name
(number->string (+ (or (and (string? suffix) (string-pad
(string->number suffix)) (number->string (+ (or (and (string? suffix)
0) (string->number suffix))
.1))) 0)
1))
4 #\0))
leaf))) leaf)))