A copied directory is a new directory, so you need a new Id. This goes for
children too - a new directory will also be created for each child, so each child needs a new Id.
Original table content (indentation is for highlighting subdirectories):
id 1 - pastaA - parentDirID: null
id 2 - pastaB - parentDirID: 1
id 3 - pastaC - parentDirID: 2
id 4 - pastaD - parentDirID: null
id 5 - pastaE - parentDirID: 4
id 6 - pastaF - parentDirID: 5
Now we will copy the pastaE
down from pastaB
.
New directories will be generated pastaE
and pastaF
, therefore new Ids. Table content after copy:
id 1 - pastaA - parentDirID: null
id 2 - pastaB - parentDirID: 1
id 3 - pastaC - parentDirID: 2
id 7 - pastaE - parentDirID: 2
id 8 - pastaF - parentDirID: 7
id 4 - pastaD - parentDirID: null
id 5 - pastaE - parentDirID: 4
id 6 - pastaF - parentDirID: 5
Completion
To the move a directory, just changes its Parent ID.
To the copy a directory, a directory new is created, so you need a new ID. A new directory is also created for each subdirectory, and each of these new subdirectories points to your Parent ID for the newly created parent ID.
As for the files, new ones will also be created in a copy, so they will also receive new Ids and new Ids.
Another modeling option
Your current modeling can be quite difficult to maintain. I would do so:
Diretorios
id - caminho
1 - pastaA
2 - pastaA/pastaB
3 - pastaA/pastaB/pastaC
Arquivos
id - id_diretorio
1 - 1
2 - 1
3 - 2
It’s simpler - no hierarchy of records, will save a lot of code and simplify reading the table content.
Put the code/template to one to see how you’re doing and better understand what the problem is. Maybe your problem is something else. Maybe you are modeling wrong, a directory should not depend on the location of your father.
– Maniero
@bigown ,but that’s exactly how the system is here. If the parentDir is null, then it’s root, if it has something it’s child of the same.
– War Lock
I keep saying you need to put more information from your code/template.
– Maniero
@bigown just posted a print, the same is just a table for the directory, the rest is files, but in relation to files it is all right to copy and move, because it does not depend on children, but for the directory I could only move.
– War Lock
This doesn’t show what you’re putting up. I don’t know what information goes there. I don’t know what that is
REFERENCIA
. In my mind change thePARENT
of a directory should not invalidate the directories that point to that directory as itsPARENT
. I don’t see why I would do this. But if you’re doing it you need to show it. It’s the last attempt to get relevant information before I give up.– Maniero
pq the Parent points to the DIRECTORY then when I copy a directory I add a new one and the same goes with a new ID so the references to this new one are invalid.. Reference also do not know came.
– War Lock