Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/src/components/cards/watcher-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default function WatcherCard({
<TextInfo className={styles['text-info']} label='Start Queue'>
{Boolean(watcher.start_queue) ? 'Yes' : 'No'}
</TextInfo>
<TextInfo className={styles['text-info']} label='Poll for Changes'>
{Boolean(watcher.use_polling) ? 'Yes' : 'No'}
</TextInfo>
</div>
</div>
<div className={styles['rules']}>
Expand Down
13 changes: 13 additions & 0 deletions client/src/components/overlays/register-watcher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function RegisterWatcher({ onClose }: Properties) {
const [presetID, setPresetID] = useState('');
const [startQueue, setStartQueue] = useState(false);
const [isDefaultPreset, setIsDefaultPreset] = useState(false);
const [usePolling, setUsePolling] = useState(false);

const canSubmit = watchPath && presetID;

Expand Down Expand Up @@ -54,13 +55,20 @@ export default function RegisterWatcher({ onClose }: Properties) {
setStartQueue(newState);
};

const handleUsePollingChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const newState = event.target.checked;

setUsePolling(newState);
};

const handleSubmit = () => {
const newWatcher: AddWatcherType = {
watch_path: watchPath,
output_path: outputPath ? outputPath : null,
preset_category: presetCategory,
preset_id: presetID,
start_queue: startQueue,
use_polling: usePolling,
};
socket.emit('add-watcher', newWatcher);
onClose();
Expand Down Expand Up @@ -154,6 +162,11 @@ export default function RegisterWatcher({ onClose }: Properties) {
checked={startQueue}
onChange={handleStartQueueChange}
/>
<ToggleInput
label='Poll for Changes (use with network mounts)'
checked={usePolling}
onChange={handleUsePollingChange}
/>
{/* <div className='inline'>
<SelectInput
id='watcher-mask-select'
Expand Down
1 change: 1 addition & 0 deletions server/src/scripts/database/database-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const selectFromWatchersDetailed = database
'watchers.preset_category',
'watchers.preset_id',
'watchers.start_queue',
'watchers.use_polling',
jsonArrayFrom(
eb
.selectFrom('watcher_rules')
Expand Down
19 changes: 19 additions & 0 deletions server/src/scripts/database/migrations/migration-3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Kysely } from 'kysely';
import logger from 'logging';

export async function up(db: Kysely<any>): Promise<void> {
logger.info(`[database] [migration-3] Adding column 'use_polling' to the table 'watchers'.`);

await db.schema
.alterTable('watchers')
.addColumn('use_polling', 'boolean', (col) => col.notNull().defaultTo(false))
.execute();
}

export async function down(db: Kysely<any>): Promise<void> {
logger.info(
`[database] [migration-3] Removing the column 'use_polling' from the table 'watchers'.`
);

await db.schema.alterTable('watchers').dropColumn('use_polling').execute();
}
1 change: 1 addition & 0 deletions server/src/scripts/database/plugins/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class CustomMigrationProvider implements MigrationProvider {
const migrations: Record<string, Migration> = {
'migration-1': await import('../migrations/migration-1'),
'migration-2': await import('../migrations/migration-2'),
'migration-3': await import('../migrations/migration-3'),
};

return migrations;
Expand Down
1 change: 1 addition & 0 deletions server/src/scripts/database/utilities/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export async function InitializeDatabaseTables() {
.addColumn('preset_category', 'text', (col) => col.notNull())
.addColumn('preset_id', 'text', (col) => col.notNull())
.addColumn('start_queue', 'boolean', (col) => col.notNull().defaultTo(false))
.addColumn('use_polling', 'boolean', (col) => col.notNull().defaultTo(false))
.execute();
logger.info(`[server] [database] Initialized the 'watchers' table.`);

Expand Down
1 change: 1 addition & 0 deletions server/src/scripts/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function RegisterWatcher(watcher: DetailedWatcherType) {
awaitWriteFinish: true,
ignoreInitial: true,
ignorePermissionErrors: true,
usePolling: watcher.use_polling,
});

newWatcher.on('add', (path) => {
Expand Down
1 change: 1 addition & 0 deletions shared/src/types/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface WatchersTable {
watch_path: string;
watcher_id: Generated<number>;
start_queue: boolean;
use_polling: boolean;
}

// Watcher Rules -----------------------------------------------------------------------
Expand Down