Giter Site home page Giter Site logo

Comments (4)

fjollberg avatar fjollberg commented on August 21, 2024

Having thought one moment more on this, I think a preferrable solution would be in the order of:

Get-Item -Path $tempDirectory, $Location | ForEach-Object { $_.Delete() }

An error would stop with:

MethodInvocationException: Exception calling "Delete" with "0" argument(s): "The directory is not empty. : '\some\path"

from robocopyps.

sbergwall avatar sbergwall commented on August 21, 2024

This should be fixed in the dev branch with version 0.2.13, but I will continue to work on the error handling for this function.

There current is a non-breaking bug that I know of. Lets say we try to remove a folder containing a file and we do not have access to remove it, if we run Remove-RoboItem with -ErrorAction Continue the error that will be shown will say the error is from Invoke-Robocopy but will still remove the remaining files in the folder we have access to.

PS> Remove-RoboItem -Path "C:\folder"
Invoke-RoboCopy : Deleting Extra File C:\folder\log.txt. Access is denied.

If we instead use -ErrorAction Stop the error handling will be correct but no more files will be removed, even if we have access to do so.

PS> Remove-RoboItem -Path "C:\folder" -ErrorAction Stop
Remove-RoboItem : Deleting Extra File C:\C:\folder\log.txt. Access is denied.

The bug is that even if we use -ErrorAction Continue the correct name of the function should be shown in the error message.

from robocopyps.

fjollberg avatar fjollberg commented on August 21, 2024

Yes, it's a bit non-trivial. The issue with hanging scripts due to remove-item is fixed in dev, much appreciated.
But I'm still struggling a bit with error handling.

Currently, it seems like Remove-RoboItem returns on an error, but the Robocopy process is still running, causing the script to wait for the now seemingly detached process to die.

E.g. I get output such as this in some circumstances:
Apr 27, 2022 5:29 AM [error] ERROR: RETRY LIMIT EXCEEDED.. *EXTRA Dir -1 \Some\path\some\item
Apr 27, 2022 5:49 AM [error] Exception calling "Delete" with "0" argument(s): "The directory is not empty. : '\Some\path'"

After which my script proceeds to the end where it is waiting, and the robocopy.exe process is still running. I'm not 100% sure what it is doing at that point. Killing it causes the script to terminate.

My script proceeding also indicate that Remove-RoboItem returns with the property Success=$true.

I've added -InformationAction Ignore in order to get rid of a lot of ouput (these can be very, very large directory structures). I've now also added -ErrorAction Stop to see if that causes the script to properly detect an issue.

from robocopyps.

sbergwall avatar sbergwall commented on August 21, 2024

All this should be fixed in the master branch, version 0.2.15.

from robocopyps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.