Skip to content

Commit

Permalink
Feature/support new tachiyomi backup file extension (#430)
Browse files Browse the repository at this point in the history
* [Codegen] Fix restore backup mutation/query

The server doesn't support nested objects for file uploads

* Support new tachiyomi backup extension
  • Loading branch information
schroda authored Oct 28, 2023
1 parent 5a5b12a commit 30fd8b0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/lib/graphql/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,7 @@ export type CreateBackupMutationVariables = Exact<{
export type CreateBackupMutation = { __typename?: 'Mutation', createBackup: { __typename?: 'CreateBackupPayload', clientMutationId?: string | null, url: string } };

export type RestoreBackupMutationVariables = Exact<{
input: RestoreBackupInput;
backup: Scalars['Upload']['input'];
}>;


Expand Down Expand Up @@ -2409,7 +2409,7 @@ export type StopUpdaterMutationVariables = Exact<{
export type StopUpdaterMutation = { __typename?: 'Mutation', updateStop: { __typename?: 'UpdateStopPayload', clientMutationId?: string | null } };

export type ValidateBackupQueryVariables = Exact<{
input: ValidateBackupInput;
backup: Scalars['Upload']['input'];
}>;


Expand Down
4 changes: 2 additions & 2 deletions src/lib/graphql/mutations/BackupMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const CREATE_BACKUP = gql`
`;

export const RESTORE_BACKUP = gql`
mutation RESTORE_BACKUP($input: RestoreBackupInput!) {
restoreBackup(input: $input) {
mutation RESTORE_BACKUP($backup: Upload!) {
restoreBackup(input: { backup: $backup }) {
clientMutationId
status {
mangaProgress
Expand Down
4 changes: 2 additions & 2 deletions src/lib/graphql/queries/BackupQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import gql from 'graphql-tag';

export const VALIDATE_BACKUP = gql`
query VALIDATE_BACKUP($input: ValidateBackupInput!) {
validateBackup(input: $input) {
query VALIDATE_BACKUP($backup: Upload!) {
validateBackup(input: { backup: $backup }) {
missingSources {
id
name
Expand Down
6 changes: 3 additions & 3 deletions src/lib/requests/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ export class RequestManager {
const result = this.doRequest<RestoreBackupMutation, RestoreBackupMutationVariables>(
GQLMethod.MUTATION,
RESTORE_BACKUP,
{ input: { backup: file } },
{ backup: file },
{
...options,
},
Expand All @@ -1584,11 +1584,11 @@ export class RequestManager {
return result;
}

public useValidateBackupFile(
public validateBackupFile(
file: File,
options?: QueryOptions<ValidateBackupQueryVariables, ValidateBackupQuery>,
): AbortabaleApolloQueryResponse<ValidateBackupQuery> {
return this.doRequest(GQLMethod.QUERY, VALIDATE_BACKUP, { input: { backup: file } }, options);
return this.doRequest(GQLMethod.QUERY, VALIDATE_BACKUP, { backup: file }, options);
}

public getExportBackupUrl(): string {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/settings/Backup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function Backup() {
useSetDefaultBackTo('settings');

const submitBackup = (file: File) => {
if (file.name.toLowerCase().endsWith('proto.gz')) {
if (file.name.toLowerCase().match(/proto\.gz$|tachibk$/g)) {
makeToast(t('settings.backup.label.restoring_backup'), 'info');
requestManager
.restoreBackupFile(file)
Expand Down

0 comments on commit 30fd8b0

Please sign in to comment.