Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

does delete directory follow links> #4530

drdt ·

Last night a lot of data spontaneously disappeared from a network drive. We believe this is because of a script that runs during the build, that creates a soft link from the QB workspace to an external location.

We have a nightly process that retires obsolete configurations, and as part of that step runs "configuration.workspaceDir.deleteDir()".
We think that this delete process followed the link and deleted everything in the target location.

Is this expected behavior?

Also, when it does the delete, does it delete the workspace on just the server, or does it go to each agent and delete there as well?

  • replies 7
  • views 1031
  • stars 1
robinshen ADMIN ·

Do you mean system.configurationManager.delete(conf)? If so, QB will try to delete all workspaces on server and all connected build agents. However it only deletes the symbol link itself, and will not touch link targets.

drdt ·

This the actual code from our script:

if (configuration.workspaceDir.exists()) configuration.workspaceDir.deleteDir();
system.configurationManager.delete( configuration );

We delete the workspace first because I didn't expect system.configurationManager.delete() to clean up the workspaces. Does the deleteDir() function also only delete the symbol link itself?

drdt ·

Here is the situation we are in:

Shortly after midnight Tuesday morning, the entire contents of the storage directory (storage/builds/..., storage/configurations/..., also we keep our backups there /storage/backups/) was removed with no warning and no complaints (QB didn't notice, just kept doing its thing). The next morning, we lost the entire contents of the QB user's home directory.

Both were restored from backup, but we are looking for a cause. We do not believe it was user error. This script is the most likely culprit.

robinshen ADMIN ·

Both workspaceDir.deleteDir() and configurationManager.delete(configuration) will delete symbol links, but will never delete linked targets. However workspaceDir itself may point to some different directories if you are using variables in its definition (check advanced setting of configuration) and if the variable evaluates to a different value. You may print its workspaceDir in your script to see what it the real value is.

drdt ·

We just had a recurrence of the same problem, and there is no doubt that QB followed the symlink executing this code:

if (configuration.workspaceDir.exists()) configuration.workspaceDir.deleteDir();

We are reproducing the failure in a controlled environment and will follow up with a support ticket.

robinshen ADMIN ·

Please use com.pmease.quickbuild.util.FileUtils.deleteDir(configuration.workspaceDir) instead.

tdeemer ·

Thank you, using this function fixes the issue. It did not follow symlinks while java.io.File.deleteDir did.