update libs

This commit is contained in:
Tigor Hutasuhut 2024-04-14 13:11:10 +07:00
parent 8d2d44597c
commit 24c5907e54
3 changed files with 21 additions and 1 deletions

View file

@ -147,7 +147,7 @@ func (api *API) downloadSubredditImage(ctx context.Context, post reddit.Post, de
return nil return nil
} }
if !errors.Is(errStat, os.ErrNotExist) { if !errors.Is(errStat, os.ErrNotExist) {
return errs.Wrapw(err, "failed to check thumbail existence", "path", thumbnailPath) return errs.Wrapw(err, "failed to check thumbnail existence", "path", thumbnailPath)
} }
thumbnailSource, err := imaging.Open(tmpImageFile.filename) thumbnailSource, err := imaging.Open(tmpImageFile.filename)

View file

@ -235,6 +235,19 @@ func (post *Post) GetThumbnailTargetPath(cfg *config.Config) string {
return path.Join(baseDownloadDir, "_thumbnails", post.GetSubreddit(), post.GetImageFilename()) return path.Join(baseDownloadDir, "_thumbnails", post.GetSubreddit(), post.GetImageFilename())
} }
func (post *Post) GetThumbnailRelativePath() string {
return path.Join("_thumbnails", post.GetSubreddit(), post.GetImageFilename())
}
func (post *Post) GetImageRelativePath(device queries.Device) string {
return path.Join(device.Name, post.GetSubreddit(), post.GetImageFilename())
}
func (post *Post) GetWindowsWallpaperImageRelativePath(device queries.Device) string {
filename := fmt.Sprintf("%s_%s", post.GetSubreddit(), post.GetImageFilename())
return path.Join(device.Name, filename)
}
func (post *Post) GetImageFilename() string { func (post *Post) GetImageFilename() string {
if !post.IsImagePost() { if !post.IsImagePost() {
return "" return ""

7
db/queries/devices.sql Normal file
View file

@ -0,0 +1,7 @@
-- name: GetDevices :many
SELECT * FROM devices;
-- name: CreateDevice :one
INSERT INTO devices (name, resolution_x, resolution_y, aspect_ratio_tolerance, min_x, min_y, max_x, max_y, nsfw, windows_wallpaper_mode)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING *;