mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	refactor(server): use insert instead of save
This commit is contained in:
		
							parent
							
								
									2a1d9a7428
								
							
						
					
					
						commit
						8b5a1faaa4
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -107,7 +107,7 @@ async function save(file: DriveFile, path: string, name: string, type: string, h
 | 
				
			||||||
		file.size = size;
 | 
							file.size = size;
 | 
				
			||||||
		file.storedInternal = false;
 | 
							file.storedInternal = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return await DriveFiles.save(file);
 | 
							return await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0]));
 | 
				
			||||||
	} else { // use internal storage
 | 
						} else { // use internal storage
 | 
				
			||||||
		const accessKey = uuid();
 | 
							const accessKey = uuid();
 | 
				
			||||||
		const thumbnailAccessKey = 'thumbnail-' + uuid();
 | 
							const thumbnailAccessKey = 'thumbnail-' + uuid();
 | 
				
			||||||
| 
						 | 
					@ -140,7 +140,7 @@ async function save(file: DriveFile, path: string, name: string, type: string, h
 | 
				
			||||||
		file.md5 = hash;
 | 
							file.md5 = hash;
 | 
				
			||||||
		file.size = size;
 | 
							file.size = size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return await DriveFiles.save(file);
 | 
							return await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0]));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -436,7 +436,7 @@ export default async function(
 | 
				
			||||||
			file.type = info.type.mime;
 | 
								file.type = info.type.mime;
 | 
				
			||||||
			file.storedInternal = false;
 | 
								file.storedInternal = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			file = await DriveFiles.save(file);
 | 
								file = await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0]));
 | 
				
			||||||
		} catch (e) {
 | 
							} catch (e) {
 | 
				
			||||||
			// duplicate key error (when already registered)
 | 
								// duplicate key error (when already registered)
 | 
				
			||||||
			if (isDuplicateKeyValueError(e)) {
 | 
								if (isDuplicateKeyValueError(e)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue