File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ public function __destruct()
4545 */
4646 public function doRun (InputInterface $ input , OutputInterface $ output ): int
4747 {
48- $ this ->fileLocker ->setCommandName ($ this ->getCommandName ($ input ))-> initLockFile () ;
48+ $ this ->fileLocker ->setCommandName ($ this ->getCommandName ($ input ));
4949
5050 try {
5151 $ this ->fileLocker ->lock ();
Original file line number Diff line number Diff line change @@ -32,9 +32,8 @@ class FileLocker implements FileLockerInterface
3232 */
3333 public function initLockFile (): self
3434 {
35- if ($ this ->enabled ) {
36- $ this ->lockFile = fopen ($ this ->getLockFilePath (), 'w+ ' );
37- }
35+ $ this ->lockFile = fopen ($ this ->getLockFilePath (), 'w+ ' );
36+
3837 return $ this ;
3938 }
4039
@@ -135,6 +134,12 @@ public function lock(): void
135134 return ;
136135 }
137136
137+ if (empty ($ this ->commandName )) {
138+ return ;
139+ }
140+
141+ $ this ->initLockFile ();
142+
138143 if (!flock ($ this ->lockFile , LOCK_EX |LOCK_NB , $ wouldBlock )) {
139144 if ($ wouldBlock ) {
140145 throw new \Exception ('Another process holds the lock! ' );
@@ -150,7 +155,11 @@ public function unlock(): void
150155 if (!$ this ->enabled ) {
151156 return ;
152157 }
153-
158+
159+ if (empty ($ this ->commandName )) {
160+ return ;
161+ }
162+
154163 flock ($ this ->lockFile , LOCK_UN );
155164 fclose ($ this ->lockFile );
156165 }
You can’t perform that action at this time.
0 commit comments