-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start-GSDriveFileUpload does not release file lock when upload is complete #144
Comments
@richmcd - Thanks for opening this up! The Let me do some playing around with it and see if I can add in the additional call to run the continuation task and dispose of the stream ASAP once the upload is complete! Adding |
Did a bit more testing and it looks like adding Working on updating that tonight! I'll update here once this has been deployed to the PS Gallery! |
One thing to note though is that, until the stream is disposed, the removed file will be visible in the filesystem but access will be locked. The code around UploadAsync for To visualize this, you can use the following code (just update the first line with a test file): $file = (Resolve-Path .\README.md).Path
$stream = New-Object 'System.IO.FileStream' $file,([System.IO.FileMode]::Open),([System.IO.FileAccess]::Read),([System.IO.FileShare]::Delete + [System.IO.FileShare]::ReadWrite)
Remove-Item $file -Force
Get-Content $file | Out-Null #1
$stream.Dispose()
Get-Content $file | Out-Null #2 You should get an Access Denied error as well as a As soon as |
Thanks @scrthq, it's odd that $stream.Dispose() should take so long in the normal circumstance. Might have something to do with the upload session object still having a reference to it or something garbage collection related. |
@richmcd - yeah, it looks like something to do with Going to work on a couple options including adding in the |
@richmcd - PSGSuite v2.22.2 is now deployed! Here's the quick summary of updates and how they relate to your workflow:
|
Sounds awesome @scrthq! has this been pushed to the gallery? |
@richmcd yup! |
Sweet! Thanks for your work on this. This is one of the most useful modules I've ever seen and appreciate your responsiveness here. |
@richmcd my pleasure!! I'm glad it's working well for you!! Let me know how the changes work for ya and if you have any issues with the new version!! |
@scrthq, The new version solves the issue, but seems to have introduced a new one. Edit: This doesn't affect the actual upload and I can ignore those errors, but it might trip up some scripts. |
@richmcd - Interesting! Are you able to run the following and if so, does it throw an error or just work? [System.Console]::CursorVisible
[System.Console]::CursorVisible = $false
[System.Console]::CursorVisible = $true This is in place to re-show the cursor when ran in a non-Windows PowerShell console (i.e. VS Code or *nix terminal), but I can remove it if it's causing more harm than good. I can't reproduce the error on my end though. Also, what version of PS are you using? |
@scrthq, I'm using Windows PowerShell 5.1, but interesting note, it only seems to happen in the PowerShell ISE console. I can run those commands in a standard PowerShell console without issue. |
Alright, yup, looks to be limited to ISE only, I'm able to replicate there.
That's easy enough to factor in though! I'll get a fix out shortly. Thanks
for digging in!!
…On Tue, Jan 15, 2019 at 3:19 PM Richard McDaniel ***@***.***> wrote:
@scrthq <https://github.com/scrthq>, I'm using Windows PowerShell 5.1,
but interesting note, it only seems to happen in the PowerShell ISE
console. I can run those commands in a standard PowerShell console without
issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#144 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMIo3csK-bDTz0_N9AcAZzHOTLYa9knEks5vDkXwgaJpZM4Z_nez>
.
|
@richmcd v2.22.3 pushed with the additional guard around that call to |
@scrthq, Yup issue fixed. Thanks again. |
Perfect! You bet!! |
When uploading a file from the local system to Google Drive using the Start-GSDriveFileUpload cmdlet the file completes but is not able to be modified, moved, or deleted once the upload is complete until the PowerShell session is closed. This seems to be because the upload does not clean itself up or release the file lock when it completes. This makes scripting of uploads that then archive or clean up the original files difficult. Either the upload needs to clean itself up after completing successfully, or at least release the lock on the uploaded file.
This could also be accomplished with a new cmdlet to Stop-GSDriveFileUploads, preferably one that takes objects from Get-GSDriveFileUplaodStatus on the pipeline, or add a switch or parameter to Get-GSDriveFileUploadStatus which would clean up the completed upload(s).
My specific case involved uploading a password protected XLSX file to a folder on a team drive using Start-GSDriveFileUpload with the -Wait switch. My expected behavior was to have no lingering upload tasks, or at least have some method to clear them once verified without having to close the session.
The text was updated successfully, but these errors were encountered: