mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add database optimise task (#3929)
* Add database optimise task * Wrap errors * US internationalisation --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
mutateAnonymiseDatabase,
|
||||
mutateMigrateSceneScreenshots,
|
||||
mutateMigrateBlobs,
|
||||
mutateOptimiseDatabase,
|
||||
} from "src/core/StashService";
|
||||
import { useToast } from "src/hooks/Toast";
|
||||
import downloadFile from "src/utils/download";
|
||||
@@ -338,6 +339,24 @@ export const DataManagementTasks: React.FC<IDataManagementTasks> = ({
|
||||
}
|
||||
}
|
||||
|
||||
async function onOptimiseDatabase() {
|
||||
try {
|
||||
await mutateOptimiseDatabase();
|
||||
Toast.success({
|
||||
content: intl.formatMessage(
|
||||
{ id: "config.tasks.added_job_to_queue" },
|
||||
{
|
||||
operation_name: intl.formatMessage({
|
||||
id: "actions.optimise_database",
|
||||
}),
|
||||
}
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
Toast.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function onAnonymise(download?: boolean) {
|
||||
try {
|
||||
setIsAnonymiseRunning(true);
|
||||
@@ -419,6 +438,25 @@ export const DataManagementTasks: React.FC<IDataManagementTasks> = ({
|
||||
setOptions={(o) => setCleanOptions(o)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Setting
|
||||
headingID="actions.optimise_database"
|
||||
subHeading={
|
||||
<>
|
||||
<FormattedMessage id="config.tasks.optimise_database" />
|
||||
<br />
|
||||
<FormattedMessage id="config.tasks.optimise_database_warning" />
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Button
|
||||
id="optimiseDatabase"
|
||||
variant="danger"
|
||||
onClick={() => onOptimiseDatabase()}
|
||||
>
|
||||
<FormattedMessage id="actions.optimise_database" />
|
||||
</Button>
|
||||
</Setting>
|
||||
</SettingSection>
|
||||
|
||||
<SettingSection headingID="metadata">
|
||||
@@ -519,7 +557,7 @@ export const DataManagementTasks: React.FC<IDataManagementTasks> = ({
|
||||
)}
|
||||
>
|
||||
<Button
|
||||
id="backup"
|
||||
id="anonymise"
|
||||
variant="secondary"
|
||||
type="submit"
|
||||
onClick={() => onAnonymise()}
|
||||
@@ -533,7 +571,7 @@ export const DataManagementTasks: React.FC<IDataManagementTasks> = ({
|
||||
subHeadingID="config.tasks.anonymise_and_download"
|
||||
>
|
||||
<Button
|
||||
id="anonymousDownload"
|
||||
id="anonymiseDownload"
|
||||
variant="secondary"
|
||||
type="submit"
|
||||
onClick={() => onAnonymise(true)}
|
||||
|
||||
@@ -2138,6 +2138,11 @@ export const mutateAnonymiseDatabase = (input: GQL.AnonymiseDatabaseInput) =>
|
||||
variables: { input },
|
||||
});
|
||||
|
||||
export const mutateOptimiseDatabase = () =>
|
||||
client.mutate<GQL.OptimiseDatabaseMutation>({
|
||||
mutation: GQL.OptimiseDatabaseDocument,
|
||||
});
|
||||
|
||||
export const mutateMigrateHashNaming = () =>
|
||||
client.mutate<GQL.MigrateHashNamingMutation>({
|
||||
mutation: GQL.MigrateHashNamingDocument,
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
"not_running": "not running",
|
||||
"open_in_external_player": "Open in external player",
|
||||
"open_random": "Open Random",
|
||||
"optimise_database": "Optimise Database",
|
||||
"overwrite": "Overwrite",
|
||||
"play_random": "Play Random",
|
||||
"play_selected": "Play selected",
|
||||
@@ -484,6 +485,8 @@
|
||||
},
|
||||
"migrations": "Migrations",
|
||||
"only_dry_run": "Only perform a dry run. Don't remove anything",
|
||||
"optimise_database": "Attempt to improve performance by analysing and then rebuilding the entire database file.",
|
||||
"optimise_database_warning": "Warning: while this task is running, any operations that modify the database will fail, and depending on your database size, it could take several minutes to complete. It also requires at the very minimum as much free disk space as your database is large, but 1.5x is recommended.",
|
||||
"plugin_tasks": "Plugin Tasks",
|
||||
"scan": {
|
||||
"scanning_all_paths": "Scanning all paths",
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"optimise_database": "Optimize Database",
|
||||
"performer_favorite": "Performer Favorited"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user