Skip to content

Commit e16366b

Browse files
author
Andrew Welch
committed
Merge branch 'release/1.2.14' into v1
2 parents 59b7b12 + b3880f3 commit e16366b

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Transcoder Changelog
22

3+
## 1.2.14 - 2021.01.03
4+
### Changed
5+
* Changed how we detect whether the transcoding processing is running, so it will work with Alpine Linux
6+
37
## 1.2.13 - 2020.12.21 [CRITICAL]
48
### Security
59
* Added a `$enableDownloadFileEndpoint` settings/config option (set to `false` by default) to control whether the download files action is publicly accessible

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nystudio107/craft-transcoder",
33
"description": "Transcode video & audio files to various formats, and provide video thumbnails",
44
"type": "craft-plugin",
5-
"version": "1.2.13",
5+
"version": "1.2.14",
66
"keywords": [
77
"craft",
88
"cms",

src/services/Transcode.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
188188
$lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock';
189189
$oldPid = @file_get_contents($lockFile);
190190
if ($oldPid !== false) {
191-
exec("ps $oldPid", $ProcessState);
192-
if (\count($ProcessState) >= 2) {
191+
// See if the process is running, and empty result means the process is still running
192+
// ref: https://stackoverflow.com/questions/3043978/how-to-check-if-a-process-id-pid-exists
193+
exec("kill -0 $oldPid 2>&1", $ProcessState);
194+
if (\count($ProcessState) === 0) {
193195
return $result;
194196
}
195197
// It's finished transcoding, so delete the lockfile and progress file
@@ -414,8 +416,10 @@ public function getAudioUrl($filePath, $audioOptions): string
414416
$lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.lock';
415417
$oldPid = @file_get_contents($lockFile);
416418
if ($oldPid !== false) {
417-
exec("ps $oldPid", $ProcessState);
418-
if (\count($ProcessState) >= 2) {
419+
// See if the process is running, and empty result means the process is still running
420+
// ref: https://stackoverflow.com/questions/3043978/how-to-check-if-a-process-id-pid-exists
421+
exec("kill -0 $oldPid 2>&1", $ProcessState);
422+
if (\count($ProcessState) === 0) {
419423
return $result;
420424
}
421425
// It's finished transcoding, so delete the lockfile and progress file
@@ -675,8 +679,10 @@ public function getGifUrl($filePath, $gifOptions): string
675679
$lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock';
676680
$oldPid = @file_get_contents($lockFile);
677681
if ($oldPid !== false) {
678-
exec("ps $oldPid", $ProcessState);
679-
if (\count($ProcessState) >= 2) {
682+
// See if the process is running, and empty result means the process is still running
683+
// ref: https://stackoverflow.com/questions/3043978/how-to-check-if-a-process-id-pid-exists
684+
exec("kill -0 $oldPid 2>&1", $ProcessState);
685+
if (\count($ProcessState) === 0) {
680686
return $result;
681687
}
682688
// It's finished transcoding, so delete the lockfile and progress file

0 commit comments

Comments
 (0)