Cleanup of old code, moved Node class, many improvements on file handling

This commit is contained in:
Magnus Åhall 2026-06-29 10:43:21 +02:00
parent 65f8cd14a7
commit 16992db6b1
19 changed files with 485 additions and 3281 deletions

37
file.go
View file

@ -129,6 +129,43 @@ func FileCountForUser(userID int) (count int, err error) { // {{{
err = row.Scan(&count)
return
} // }}}
func FileServerUUIDsForUser(userID, page int) (uuids []string, more bool, err error) { // {{{
uuids = []string{}
var rows *sqlx.Rows
rows, err = db.Queryx(`
SELECT
uuid
FROM public.file
WHERE
user_id = $1
ORDER BY
uuid ASC
LIMIT $2 OFFSET $3
`,
userID,
SYNC_PAGINATION+1,
page*SYNC_PAGINATION,
)
if err != nil {
return
}
defer rows.Close()
var uuid string
for rows.Next() {
err = rows.Scan(&uuid)
if err != nil {
return
}
uuids = append(uuids, uuid)
}
more = len(uuids) > SYNC_PAGINATION
uuids = uuids[0:min(SYNC_PAGINATION, len(uuids))]
return
} // }}}
func FileMetadata(userID int, uuid string) (f File, err error) { // {{{
row := db.QueryRowx(`SELECT * FROM public.file WHERE user_id = $1 AND "uuid" = $2`, userID, uuid)
err = row.StructScan(&f)