Comments (4)
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.
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.
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.
All this should be fixed in the master branch, version 0.2.15.
from robocopyps.
Related Issues (20)
- Issue when using special character on Source/Path
- PS v5: Issue using multiple paths in Get-RoboItem
- Parser fails to interpret hours more than 24:00:00 on long runs HOT 3
- Remove-RoboItem is not using created temporary folder HOT 2
- Get-RoboItem with -Unit GB on small items gives weird TotalSize HOT 1
- Fix auto loading of module HOT 1
- Robocopy issue HOT 3
- Win11: Speed not parsed correctly
- differential backup HOT 1
- Incompatible with PowerShell 7.3+ HOT 3
- [Request] Add option to clear `$global:LastExitCode` on success HOT 1
- when line cannot be parsed, function may be called on null-valued expression in Invoke-RobocopyParser HOT 5
- should use $WhatIfPreference rather than $WhatIf
- add function to append log
- add /v switch HOT 1
- create parametersetname
- Create example with Job options
- Fix Pester tests
- Add include/exclude files and directories to Get-RoboItem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robocopyps.