fix(duplicator): automatic file path recognition
This commit is contained in:
		
							parent
							
								
									68511f05bc
								
							
						
					
					
						commit
						d7dad1855f
					
				@ -1,4 +1,5 @@
 | 
				
			|||||||
import decompress from 'decompress';
 | 
					import decompress from 'decompress';
 | 
				
			||||||
 | 
					import fs from 'fs';
 | 
				
			||||||
import fsPromises from 'fs/promises';
 | 
					import fsPromises from 'fs/promises';
 | 
				
			||||||
import inquirer from 'inquirer';
 | 
					import inquirer from 'inquirer';
 | 
				
			||||||
import path from 'path';
 | 
					import path from 'path';
 | 
				
			||||||
@ -6,15 +7,22 @@ import { AppMigrator } from './app-migrator';
 | 
				
			|||||||
import { CollectionGroupManager } from './collection-group-manager';
 | 
					import { CollectionGroupManager } from './collection-group-manager';
 | 
				
			||||||
import { FieldValueWriter } from './field-value-writer';
 | 
					import { FieldValueWriter } from './field-value-writer';
 | 
				
			||||||
import { readLines, sqlAdapter } from './utils';
 | 
					import { readLines, sqlAdapter } from './utils';
 | 
				
			||||||
import fs from 'fs';
 | 
					 | 
				
			||||||
export class Restorer extends AppMigrator {
 | 
					export class Restorer extends AppMigrator {
 | 
				
			||||||
  direction = 'restore' as const;
 | 
					  direction = 'restore' as const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  importedCollections: string[] = [];
 | 
					  importedCollections: string[] = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async restore(backupFilePath: string) {
 | 
					  async restore(backupFilePath: string) {
 | 
				
			||||||
    const dirname = path.resolve(process.cwd(), 'storage', 'duplicator');
 | 
					    let filePath: string;
 | 
				
			||||||
    const filePath = path.isAbsolute(backupFilePath) ? backupFilePath : path.resolve(dirname, backupFilePath);
 | 
					
 | 
				
			||||||
 | 
					    if (path.isAbsolute(backupFilePath)) {
 | 
				
			||||||
 | 
					      filePath = backupFilePath;
 | 
				
			||||||
 | 
					    } else if (path.basename(backupFilePath) === backupFilePath) {
 | 
				
			||||||
 | 
					      const dirname = path.resolve(process.cwd(), 'storage', 'duplicator');
 | 
				
			||||||
 | 
					      filePath = path.resolve(dirname, backupFilePath);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      filePath = path.resolve(process.cwd(), backupFilePath);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const results = await inquirer.prompt([
 | 
					    const results = await inquirer.prompt([
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user