-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Lendruk/develop
Release v0.6.0
- Loading branch information
Showing
88 changed files
with
2,921 additions
and
1,727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
ALTER TABLE `media_items` ADD COLUMN original_file_name TEXT DEFAULT NULL; | ||
--- StatementBreak | ||
ALTER TABLE `media_items` ADD COLUMN source TEXT DEFAULT NULL; | ||
--- StatementBreak | ||
CREATE TABLE IF NOT EXISTS `active_watchers` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`description` text NOT NULL, | ||
`status` text NOT NULL, | ||
`data` text, | ||
`items_per_request` integer NOT NULL DEFAULT 0, | ||
`items_downloaded` integer NOT NULL DEFAULT 0, | ||
`total_items` integer, | ||
`type` text NOT NULL, | ||
`url` text NOT NULL, | ||
`request_interval` integer NOT NULL DEFAULT 0, | ||
`last_requested_at` integer NOT NULL DEFAULT 0, | ||
`time_since_new_items` integer NOT NULL DEFAULT 0, | ||
`inactivity_timeout` integer NOT NULL DEFAULT 0, | ||
`created_at` integer NOT NULL | ||
); | ||
--- StatementBreak | ||
CREATE TABLE IF NOT EXISTS `active_watchers_to_tags` ( | ||
`active_watcher_id` text NOT NULL, | ||
`tag_id` text NOT NULL, | ||
PRIMARY KEY(`active_watcher_id`, `tag_id`), | ||
FOREIGN KEY (`active_watcher_id`) REFERENCES `active_watchers`(`id`) ON UPDATE no action ON DELETE cascade, | ||
FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON UPDATE no action ON DELETE cascade | ||
); | ||
--- StatementBreak | ||
CREATE TABLE IF NOT EXISTS `active_watchers_to_media_items` ( | ||
`active_watcher_id` text NOT NULL, | ||
`media_item_id` integer NOT NULL, | ||
PRIMARY KEY(`active_watcher_id`, `media_item_id`), | ||
FOREIGN KEY (`active_watcher_id`) REFERENCES `active_watchers`(`id`) ON UPDATE no action ON DELETE cascade, | ||
FOREIGN KEY (`media_item_id`) REFERENCES `media_items`(`id`) ON UPDATE no action ON DELETE cascade | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { eq } from 'drizzle-orm'; | ||
import fs from 'fs/promises'; | ||
import path from 'path'; | ||
import { mediaItems } from '../../../src/db/vault/schema'; | ||
import { VaultBase } from '../../../src/lib/VaultBase'; | ||
import { mediaService } from '../../../src/services/MediaService'; | ||
|
||
/** | ||
* Migrates 0.5.0 vaults to 0.6.0 | ||
* - Regenerates all .gif thumbnails | ||
*/ | ||
export default async (vault: VaultBase) => { | ||
// Regenerate all .gif thumbnails | ||
|
||
const images = await vault.db.query.mediaItems.findMany({ | ||
where: eq(mediaItems.extension, 'png') | ||
}); | ||
for (const potentialGif of images) { | ||
let filePath = path.join(vault.path, 'media', 'images', `${potentialGif.fileName}.png`); | ||
const fileBuffer = await fs.readFile(filePath); | ||
// https://stackoverflow.com/questions/8473703/in-node-js-given-a-url-how-do-i-check-whether-its-a-jpg-png-gif | ||
if (fileBuffer.toString('hex', 0, 4) === '47494638') { | ||
await fs.unlink(filePath); | ||
|
||
filePath = filePath.replace('.png', '.gif'); | ||
// Delete the old thumbnail | ||
await fs.unlink( | ||
path.join(vault.path, 'media', 'images', '.thumb', `${potentialGif.fileName}.jpg`) | ||
); | ||
await fs.writeFile(filePath, fileBuffer); | ||
|
||
await vault.db | ||
.update(mediaItems) | ||
.set({ extension: 'gif' }) | ||
.where(eq(mediaItems.id, potentialGif.id)); | ||
|
||
potentialGif.extension = 'gif'; | ||
mediaService.generateItemThumbnail(vault, 'webp', filePath, potentialGif); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import migration_0_6_0 from './0.6.0/migration'; | ||
|
||
export default { | ||
'0.6.0': migration_0_6_0 | ||
}; |
Oops, something went wrong.