File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -435,10 +435,17 @@ function Invoke-Ffmpeg {
435
435
# endregion
436
436
437
437
# region main entry point
438
+ [System.Threading.Mutex ]$mutex = $null
439
+ [boolean ]$gotMutex = $false
438
440
try {
439
441
Parse- Config
440
442
Examine- InputFile
441
443
Select-Codecs
444
+ $mutex = New-Object System.Threading.Mutex($false , " Global\$ ( $File.Name ) " )
445
+ $gotMutex = $mutex.WaitOne (60 * 1000 ) # 1 minute to let other process get started
446
+ if (-not $gotMutex ) {
447
+ Write-Debug " [$LOG_TAG ]Failed to get mutex. Maybe inotify double-fired?"
448
+ }
442
449
Invoke-Ffmpeg
443
450
}
444
451
catch {
@@ -450,5 +457,10 @@ catch {
450
457
Write-Error - Message $_
451
458
}
452
459
}
460
+ finally {
461
+ if ($mutex -ne $null -and $gotMutex ) {
462
+ $mutex.ReleaseMutex ()
463
+ }
464
+ }
453
465
Write-Output " [$LOG_TAG ]Complete."
454
466
# endregion
You can’t perform that action at this time.
0 commit comments