[GH-ISSUE #876] Setup fails because the file is locked #682

Closed
opened 2026-02-26 09:32:16 +03:00 by kerem · 10 comments
Owner

Originally created by @KirillOsenkov on GitHub (May 3, 2021).
Original GitHub issue: https://github.com/NickeManarin/ScreenToGif/issues/876

Originally assigned to: @NickeManarin on GitHub.

I keep my ScreenToGif.exe in my Dropbox folder, and when I updated today the setup failed with this message in the log:

▬ Message - 
	The process cannot access the file 'C:\Dropbox\Tools\ProgramFilesFolder\ScreenToGif' because it is being used by another process.
♦ Date/Hour - 
	5/2/2021 8:14:35 PM
▲ Source - 
	mscorlib
▼ TargetSite - 
	Void WinIOError(Int32, System.String)
♠ StackTrace - 
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data)
   at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
   at ScreenToGif_Installer.UserControls.Progress.CopyPortableFiles()

I'm guessing Dropbox takes some kind of a lock on files intermittently so perhaps consider adding a retry a few times?

To help with diagnosing locked files, consider using https://github.com/cklutz/LockCheck (here's a sample of how it's used in MSBuild: https://source.dot.net/#Microsoft.Build.Tasks.Core/LockCheck.cs,726a666e72008c9b)

Thanks again for the fantastic tool!

Originally created by @KirillOsenkov on GitHub (May 3, 2021). Original GitHub issue: https://github.com/NickeManarin/ScreenToGif/issues/876 Originally assigned to: @NickeManarin on GitHub. I keep my ScreenToGif.exe in my Dropbox folder, and when I updated today the setup failed with this message in the log: ``` ▬ Message - The process cannot access the file 'C:\Dropbox\Tools\ProgramFilesFolder\ScreenToGif' because it is being used by another process. ♦ Date/Hour - 5/2/2021 8:14:35 PM ▲ Source - mscorlib ▼ TargetSite - Void WinIOError(Int32, System.String) ♠ StackTrace - at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data) at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost) at ScreenToGif_Installer.UserControls.Progress.CopyPortableFiles() ``` I'm guessing Dropbox takes some kind of a lock on files intermittently so perhaps consider adding a retry a few times? To help with diagnosing locked files, consider using https://github.com/cklutz/LockCheck (here's a sample of how it's used in MSBuild: https://source.dot.net/#Microsoft.Build.Tasks.Core/LockCheck.cs,726a666e72008c9b) Thanks again for the fantastic tool!
kerem 2026-02-26 09:32:16 +03:00
Author
Owner

@NickeManarin commented on GitHub (May 8, 2021):

Looks like that you are using the portable variant, is that right?

The update process calls the installer to run a custom action.
It looks like doable.

Thanks for the feedback and the proposed solution.

<!-- gh-comment-id:835558948 --> @NickeManarin commented on GitHub (May 8, 2021): Looks like that you are using the portable variant, is that right? The update process calls the installer to run a custom action. It looks like doable. Thanks for the feedback and the proposed solution.
Author
Owner

@NickeManarin commented on GitHub (May 25, 2021):

The installer will try to copy/remove files multiple (~4).

<!-- gh-comment-id:847926216 --> @NickeManarin commented on GitHub (May 25, 2021): The installer will try to copy/remove files multiple (~4).
Author
Owner

@KirillOsenkov commented on GitHub (May 27, 2021):

Hmm, I've tried to update to 2.30.1 and got Setup failed again.

Here's the log:
https://gist.github.com/KirillOsenkov/41d202ebb71cab3ed31c6ef8d28b4413

For some reason it tries to access the folder D:\Dropbox\MS\Tools\ProgramFilesFolder\ScreenToGif, which I don't remember creating.

Now it has two files:
image

I'd saved ScreenToGif.exe to D:\Dropbox\MS\Tools\ScreenToGif.exe and that's where I'm running it from.

But later I did try run ScreenToGif.exe and it started the version 2.30.1 so it must have updated successfully (mostly).

<!-- gh-comment-id:849313801 --> @KirillOsenkov commented on GitHub (May 27, 2021): Hmm, I've tried to update to 2.30.1 and got Setup failed again. Here's the log: https://gist.github.com/KirillOsenkov/41d202ebb71cab3ed31c6ef8d28b4413 For some reason it tries to access the folder `D:\Dropbox\MS\Tools\ProgramFilesFolder\ScreenToGif`, which I don't remember creating. Now it has two files: ![image](https://user-images.githubusercontent.com/679326/119766957-d8521180-be6a-11eb-8bd9-e53cc1778b4b.png) I'd saved ScreenToGif.exe to `D:\Dropbox\MS\Tools\ScreenToGif.exe` and that's where I'm running it from. But later I did try run ScreenToGif.exe and it started the version 2.30.1 so it must have updated successfully (mostly).
Author
Owner

@KirillOsenkov commented on GitHub (May 27, 2021):

Consider also adding more logging, like which process is running (Process.GetCurrentProcess().MainModule.FileName), etc.

<!-- gh-comment-id:849314176 --> @KirillOsenkov commented on GitHub (May 27, 2021): Consider also adding more logging, like which process is running (`Process.GetCurrentProcess().MainModule.FileName`), etc.
Author
Owner

@KirillOsenkov commented on GitHub (May 27, 2021):

image

<!-- gh-comment-id:849314544 --> @KirillOsenkov commented on GitHub (May 27, 2021): ![image](https://user-images.githubusercontent.com/679326/119767189-41398980-be6b-11eb-9e58-42a5714f05d0.png)
Author
Owner

@NickeManarin commented on GitHub (May 28, 2021):

Ohh, Ok.

I'm going to change my approach.
Thank you for the log.

The installer in /a mode creates that folder when unpacking the files.
I just erase it after getting the necessary files from it.

<!-- gh-comment-id:850046979 --> @NickeManarin commented on GitHub (May 28, 2021): Ohh, Ok. I'm going to change my approach. Thank you for the log. The installer in `/a` mode creates that folder when unpacking the files. I just erase it after getting the necessary files from it.
Author
Owner

@NickeManarin commented on GitHub (May 29, 2021):

I changed the process, now it waits indefinitely until the process releases the file.

Update

I'm using some simple Ntdll calls.

<!-- gh-comment-id:850915964 --> @NickeManarin commented on GitHub (May 29, 2021): I changed the process, now it waits indefinitely until the process releases the file. ![Update](https://user-images.githubusercontent.com/14798947/120087639-0bd9a980-c0c0-11eb-94af-a29983e5461f.gif) I'm using some simple Ntdll calls.
Author
Owner

@KirillOsenkov commented on GitHub (Jun 5, 2021):

Thanks! Out of curiosity, where's the logic that checks for blocking files? I couldn't find it in the repo. Curious which ntdll calls you're using.

<!-- gh-comment-id:855311447 --> @KirillOsenkov commented on GitHub (Jun 5, 2021): Thanks! Out of curiosity, where's the logic that checks for blocking files? I couldn't find it in the repo. Curious which ntdll calls you're using.
Author
Owner

@NickeManarin commented on GitHub (Jun 6, 2021):

It's closed source.
I'm using something similar to LockCheck (but way more simple).
It's similar enough that I should add a license info. (I just added now, it will be available with v2.32)

<!-- gh-comment-id:855314307 --> @NickeManarin commented on GitHub (Jun 6, 2021): It's closed source. I'm using something similar to LockCheck (but way more simple). It's similar enough that I should add a license info. (I just added now, it will be available with v2.32)
Author
Owner

@KirillOsenkov commented on GitHub (Jun 6, 2021):

I'm just intrigued because I don't know of any other solution other than LockCheck, and I don't see how I would simplify it. If you can't share, that's OK, but if you can post a sample I'd be very curious to learn about it.

<!-- gh-comment-id:855330971 --> @KirillOsenkov commented on GitHub (Jun 6, 2021): I'm just intrigued because I don't know of any other solution other than LockCheck, and I don't see how I would simplify it. If you can't share, that's OK, but if you can post a sample I'd be very curious to learn about it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ScreenToGif#682
No description provided.