diff --git a/api/download_subreddit_images.go b/api/download_subreddit_images.go index f934ea6..3ee0473 100644 --- a/api/download_subreddit_images.go +++ b/api/download_subreddit_images.go @@ -147,7 +147,7 @@ func (api *API) downloadSubredditImage(ctx context.Context, post reddit.Post, de return nil } 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) diff --git a/api/reddit/post.go b/api/reddit/post.go index 72f69d8..ff0452b 100644 --- a/api/reddit/post.go +++ b/api/reddit/post.go @@ -235,6 +235,19 @@ func (post *Post) GetThumbnailTargetPath(cfg *config.Config) string { 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 { if !post.IsImagePost() { return "" diff --git a/db/queries/devices.sql b/db/queries/devices.sql new file mode 100644 index 0000000..02d60f6 --- /dev/null +++ b/db/queries/devices.sql @@ -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 *;