Closed ghost closed 6 years ago
Actually, could we just update the path on the File
instance, from within the implementation of move
.
@rob-nash Not sure what you mean. Operations on File
and Folder
that would result in their underlying file system representation changing do in fact update their internal path
(see: FileSystem.Item.move(to:)
). And since File
and Folder
are classes, when passed by reference, a change in one code path would affect the reference in another.
Can you write a test showing the behavior you're trying to design around?
Just wrote a test and I couldn't reproduce the issue. Started looking at other reason why this might be happening and it turns out I'm running code on the wrong thread.
Thanks for helping me think 'outside of the box'.
Sorry for wasting time.
Never a waste! Glad to help 👍
Hi,
There seems to be a danger passing
File
around, by reference.If I have the following
And I pass it into the following function.
Moving forward, if I interact with this same
File
reference, it may no longer have a valid path. Thestore
function above may performmoveItem
, for example.Idea 1
Perhaps we could create an alias?
Idea 2
Might it be worth making a distinction between a
File
that you know exists and aPotentialFile
that hasn't been confirmed to exist? You see this kind of 'evaluate at last minute' mentality throughout Swift.The same kind of mentality as
I suppose we would have to handle a change in state, in both directions.
PotentialFile
becomingFile
File
becomingPotentialFile
Idea 3
Perhaps we could harness this API?
FileReferenceURL
Check Resource Is Reachable