(09-30-2024, 05:46 AM)stevef Wrote: [...] The problem occurs if making a custom directory for the location using the tool. [...] directory shows it to be empty.
Hi!
I was able to reproduce the bug.
To be sure, I made a low level backup and I've tested twice, with another name for the dir: "TestLog". Same as before. Owner is Root and is empty.
I explained in a previous post what I thought has happened:
"
I will check at the next update to see if I use the Lite Dialog if this goes as "root". As far as I remember, this is possible since the MkDir is issued from inside the script and it used "sudo apt install *". Since the persistence of the Root session is long enough to allow the updates, we can have an answer here.
The only way out in this case, is adding a ChOwner after the Dir creation and before saving the file. A delay before the save instruction might also be necessary to allow the system to update the directory structure and prevent the "File Missing" error.
Also, invoking "SaveAs" dialog as Root (this is the case as I see it), will generate a chain of Root processes, hence the Dir owner is Root and the file owner is also Root."
What is difficult to explain is why all goes as expected, if another path is chosen and the MkDir is skipped.
At my first attempt, I used "/video/FileName.txt". Nothing fancy.
The difference is that the owner of "/video/" is "serban" (me) and I only saved the file. I guess I need to test again if I use the same partition but I invoke the "Create Directory" dialog, will result in a Root owned directory as well.
If the string parameter passed when invoking the Dialog contains "$USER", at that point, the contents of "$USER" is "root". Thus the MkDir will create the root owned whatever (file, directory).
The abnormality is that even so, the file should be saved. That means that somewhere along the code, the contents of a path variable is deprecated (remains the default one) in which case we get a WriteFile error which instead of rising the error message, goes unnoticed.
However, if the SaveAsDialog call exits, it should return an ErrorCode = whatever. Usually 0 if success.
If the ErrorCode is checked, than all should go as expected. Maybe this line of code is missing.
A nested conditional should check the return value of the function and branch accordingly.
If this step is skipped, the code goes on the default path (save the file in the default path) instead of retaining the new data.
The syntax of the procedure should make the options clear in both cases (SaveAs or CreateDir).
This is as far as I could get.
Is it possible that the "Save As..." dialog is re-launched in a different line of code if instead of saving the file we choose to create a new directory?
Depending on the specific implementation of the "SaveAsDialog" function (procedure?), it is possible to go to another line of code that re-launches the Dialog with another flag (parameter) in this case might be something like boolCreateDir and the class will generate another window (Create Directory) and this is owned by Root, thus any created directory will inherit the attributes.
Bestb regards, Șerban.
"It's easy to die for an idea. It's way harder TO LIVE for your idea!"
Current Machine:
Dell Precision T1700, 16 GB RAM, SSD Kingston A400, 480 GB.
Laptop:
ASUS X200MA , Intel® Celeron® N2830, 2 GB RAM, SSD Kingston A400, 480 GB.