fix: replace invalid new(expression) calls with proper pointer allocation
Go's new() builtin takes a type and allocates a zero value — it cannot wrap an expression. All instances of new(someExpression) were compile errors. Replace each with a local variable assignment and address-of operator. Affected files: - handlers/koreader.go: progress field pointers (Chapter, Page, etc.) - handlers/kobo.go: pagesRemaining pointer - handlers/queue.go: uuidPtrToString and timestamptzPtrToString helpers - router/reader.go: bookmark pageNumber and chapterNumber pointers - services/media_scanner.go: validation error message pointers - services/worker.go: StartedAt and CompletedAt timestamps - sync/offline.go: GetDeviceStatus return pointer - tests/device_test.go: SyncEnabled and SyncFrequencyMinutes pointers
This commit is contained in:
@@ -602,19 +602,24 @@ func (h *KOReaderHandler) GetMetadata(c *echo.Context) error {
|
||||
progressData.Epubcfi = &progress.Epubcfi.String
|
||||
}
|
||||
if progress.Chapter.Valid {
|
||||
progressData.Chapter = new(int(progress.Chapter.Int32))
|
||||
progress := int(progress.Chapter.Int32)
|
||||
progressData.Chapter = &progress
|
||||
}
|
||||
if progress.ChapterProgress.Valid {
|
||||
progressData.ChapterProgress = new(progress.ChapterProgress.Float64)
|
||||
progress := progress.ChapterProgress.Float64
|
||||
progressData.ChapterProgress = &progress
|
||||
}
|
||||
if progress.CharacterOffset.Valid {
|
||||
progressData.Character = new(progress.CharacterOffset.Int64)
|
||||
progress := progress.CharacterOffset.Int64
|
||||
progressData.Character = &progress
|
||||
}
|
||||
if progress.CurrentPage.Valid {
|
||||
progressData.Page = new(int(progress.CurrentPage.Int32))
|
||||
progress := int(progress.CurrentPage.Int32)
|
||||
progressData.Page = &progress
|
||||
}
|
||||
if progress.TotalPages.Valid {
|
||||
progressData.TotalPages = new(int(progress.TotalPages.Int32))
|
||||
progress := int(progress.TotalPages.Int32)
|
||||
progressData.TotalPages = &progress
|
||||
}
|
||||
|
||||
annotations, err := h.db.GetAnnotationsForBook(c.Request().Context(), database.GetAnnotationsForBookParams{
|
||||
@@ -694,7 +699,8 @@ func (h *KOReaderHandler) GetLibrary(c *echo.Context) error {
|
||||
if err == nil {
|
||||
percentRead = progress.Percentage.Float64
|
||||
if progress.TotalPages.Valid && progress.CurrentPage.Valid {
|
||||
pagesRemaining = new(int(progress.TotalPages.Int32 - progress.CurrentPage.Int32))
|
||||
pages := int(progress.TotalPages.Int32 - progress.CurrentPage.Int32)
|
||||
pagesRemaining = &pages
|
||||
}
|
||||
if progress.LastReadAt.Valid {
|
||||
lastModified = progress.LastReadAt.Time.Format(time.RFC3339)
|
||||
|
||||
Reference in New Issue
Block a user