Skip to content

Commit

Permalink
fix(folder-scanner): fix schema and preserve file
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerni10 committed Jun 21, 2023
1 parent eac1842 commit d5b0fe2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('SouthFolderScanner', () => {
}));
south.updateModifiedTime('filename', 999);
expect(database.prepare).toHaveBeenCalledWith(
`INSERT INTO folder_scanner (filename, mtime_ms) VALUES (?, ?) ON CONFLICT(name) DO UPDATE SET mtime_ms = ?`
`INSERT INTO folder_scanner (filename, mtime_ms) VALUES (?, ?) ON CONFLICT(filename) DO UPDATE SET mtime_ms = ?`
);
expect(run).toHaveBeenCalledWith('filename', 999, 999);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export default class SouthFolderScanner extends SouthConnector {
}

updateModifiedTime(filename: string, mtimeMs: number): void {
const query = `INSERT INTO ${FOLDER_SCANNER_TABLE} (filename, mtime_ms) VALUES (?, ?) ON CONFLICT(name) DO UPDATE SET mtime_ms = ?`;
this.southCacheService.southCacheRepository.database.prepare(query).run(filename, mtimeMs, mtimeMs);
const query = `INSERT INTO ${FOLDER_SCANNER_TABLE} (filename, mtime_ms) VALUES (?, ?) ON CONFLICT(filename) DO UPDATE SET mtime_ms = ?`;
const result = this.southCacheService.southCacheRepository.database.prepare(query).run(filename, mtimeMs, mtimeMs);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion backend/src/validators/joi.validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ describe('Joi validator', () => {
.allow(null)
.when('driver', {
is: Joi.any().valid('SQLite'),
then: Joi.string().allow(null).required()
then: Joi.string().allow(null).required(),
otherwise: Joi.string().allow(null).optional()
})
});
expect(expectedSchema.describe()).toEqual(generatedSchema.describe());
Expand Down
4 changes: 3 additions & 1 deletion backend/src/validators/joi.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export default class JoiValidator {
});
schema = schema.falsy(0).truthy(1);
schema = this.handleConditionalDisplay(formControl, schema) as Joi.BooleanSchema;

return {
[formControl.key]: schema
};
Expand Down Expand Up @@ -184,7 +185,8 @@ export default class JoiValidator {
Object.entries(formControl.conditionalDisplay!).forEach(([key, value]) => {
schema = schema.when(key, {
is: Joi.any().valid(...value),
then: schema.required()
then: schema.required(),
otherwise: schema.optional()
});
});
}
Expand Down

0 comments on commit d5b0fe2

Please sign in to comment.