File tree Expand file tree Collapse file tree 5 files changed +22
-11
lines changed
src/backend/src/filesystem Expand file tree Collapse file tree 5 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -614,6 +614,17 @@ export default class PuterFSProvider {
614614 return child_uuids ;
615615 }
616616
617+ async directory_has_name ( { parent, name } ) {
618+ const uid = await parent . get ( 'uid' ) ;
619+ /* eslint-disable */
620+ let check_dupe = await db . read (
621+ 'SELECT `id` FROM `fsentries` WHERE `parent_uid` = ? AND name = ? LIMIT 1' ,
622+ [ uid , name ] ,
623+ ) ;
624+ /* eslint-enable */
625+ return ! ! check_dupe [ 0 ] ;
626+ }
627+
617628 /**
618629 * Write a new file to the filesystem. Throws an error if the destination
619630 * already exists.
Original file line number Diff line number Diff line change @@ -619,6 +619,10 @@ module.exports = class FSNodeContext {
619619 }
620620
621621 if ( key === 'uid' ) {
622+ const uidSelector = this . get_selector_of_type ( NodeUIDSelector ) ;
623+ if ( uidSelector ) {
624+ return uidSelector . value ;
625+ }
622626 await this . fetchEntry ( ) ;
623627 return this . uid ;
624628 }
@@ -742,6 +746,10 @@ module.exports = class FSNodeContext {
742746
743747 return await this . fs . node ( new NodeChildSelector ( this . selector , name ) ) ;
744748 }
749+
750+ async hasChild ( name ) {
751+ return await this . provider . directory_has_name ( { parent : this , name } ) ;
752+ }
745753
746754 async getTarget ( ) {
747755 await this . fetchEntry ( ) ;
Original file line number Diff line number Diff line change @@ -173,14 +173,11 @@ class HLCopy extends HLFilesystemOperation {
173173 }
174174
175175 if ( values . dedupe_name ) {
176- const fsEntryFetcher = context . get ( 'services' ) . get ( 'fsEntryFetcher' ) ;
177176 const target_ext = _path . extname ( target_name ) ;
178177 const target_noext = _path . basename ( target_name , target_ext ) ;
179178 for ( let i = 1 ; ; i ++ ) {
180179 const try_new_name = `${ target_noext } (${ i } )${ target_ext } ` ;
181- const exists = await fsEntryFetcher . nameExistsUnderParent (
182- parent . uid , try_new_name
183- ) ;
180+ const exists = await parent . hasChild ( try_new_name ) ;
184181 if ( ! exists ) {
185182 target_name = try_new_name ;
186183 break ;
Original file line number Diff line number Diff line change @@ -152,14 +152,11 @@ class HLMove extends HLFilesystemOperation {
152152 }
153153
154154 if ( values . dedupe_name ) {
155- const svc_fsEntryFetcher = svc . get ( 'fsEntryFetcher' ) ;
156155 const target_ext = _path . extname ( target_name ) ;
157156 const target_noext = _path . basename ( target_name , target_ext ) ;
158157 for ( let i = 1 ; ; i ++ ) {
159158 const try_new_name = `${ target_noext } (${ i } )${ target_ext } ` ;
160- const exists = await svc_fsEntryFetcher . nameExistsUnderParent (
161- parent . uid , try_new_name
162- ) ;
159+ const exists = await parent . hasChild ( try_new_name ) ;
163160 if ( ! exists ) {
164161 target_name = try_new_name ;
165162 break ;
Original file line number Diff line number Diff line change @@ -251,9 +251,7 @@ class HLWrite extends HLFilesystemOperation {
251251 const target_noext = _path . basename ( target_name , target_ext ) ;
252252 for ( let i = 1 ; ; i ++ ) {
253253 const try_new_name = `${ target_noext } (${ i } )${ target_ext } ` ;
254- const exists = await fsEntryFetcher . nameExistsUnderParent (
255- parent . uid , try_new_name
256- ) ;
254+ const exists = await parent . hasChild ( try_new_name ) ;
257255 if ( ! exists ) {
258256 target_name = try_new_name ;
259257 break ;
You can’t perform that action at this time.
0 commit comments