diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-09-26 14:18:01 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-13 12:38:19 +0200 |
commit | fd1ddad98df45bc3c18be7980c1cbe68ce6b219c (patch) | |
tree | e4017d3c979604f40e78cdc305f0ab191aedd4b9 /tests/netscape/BookmarkImportTest.php | |
parent | 458b6b9918ec27154dd45416947bb93bedb97109 (diff) | |
download | Shaarli-fd1ddad98df45bc3c18be7980c1cbe68ce6b219c.tar.gz Shaarli-fd1ddad98df45bc3c18be7980c1cbe68ce6b219c.tar.zst Shaarli-fd1ddad98df45bc3c18be7980c1cbe68ce6b219c.zip |
Add mutex on datastore I/O operations
To make sure that there is no concurrent operation on the datastore file.
Fixes #1132
Diffstat (limited to 'tests/netscape/BookmarkImportTest.php')
-rw-r--r-- | tests/netscape/BookmarkImportTest.php | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/netscape/BookmarkImportTest.php b/tests/netscape/BookmarkImportTest.php index c1e49b5f..c526d5c8 100644 --- a/tests/netscape/BookmarkImportTest.php +++ b/tests/netscape/BookmarkImportTest.php | |||
@@ -3,6 +3,7 @@ | |||
3 | namespace Shaarli\Netscape; | 3 | namespace Shaarli\Netscape; |
4 | 4 | ||
5 | use DateTime; | 5 | use DateTime; |
6 | use malkusch\lock\mutex\NoMutex; | ||
6 | use Psr\Http\Message\UploadedFileInterface; | 7 | use Psr\Http\Message\UploadedFileInterface; |
7 | use Shaarli\Bookmark\Bookmark; | 8 | use Shaarli\Bookmark\Bookmark; |
8 | use Shaarli\Bookmark\BookmarkFileService; | 9 | use Shaarli\Bookmark\BookmarkFileService; |
@@ -87,6 +88,7 @@ class BookmarkImportTest extends TestCase | |||
87 | */ | 88 | */ |
88 | protected function setUp(): void | 89 | protected function setUp(): void |
89 | { | 90 | { |
91 | $mutex = new NoMutex(); | ||
90 | if (file_exists(self::$testDatastore)) { | 92 | if (file_exists(self::$testDatastore)) { |
91 | unlink(self::$testDatastore); | 93 | unlink(self::$testDatastore); |
92 | } | 94 | } |
@@ -97,7 +99,7 @@ class BookmarkImportTest extends TestCase | |||
97 | $this->conf->set('resource.page_cache', $this->pagecache); | 99 | $this->conf->set('resource.page_cache', $this->pagecache); |
98 | $this->conf->set('resource.datastore', self::$testDatastore); | 100 | $this->conf->set('resource.datastore', self::$testDatastore); |
99 | $this->history = new History(self::$historyFilePath); | 101 | $this->history = new History(self::$historyFilePath); |
100 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); | 102 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true); |
101 | $this->netscapeBookmarkUtils = new NetscapeBookmarkUtils($this->bookmarkService, $this->conf, $this->history); | 103 | $this->netscapeBookmarkUtils = new NetscapeBookmarkUtils($this->bookmarkService, $this->conf, $this->history); |
102 | } | 104 | } |
103 | 105 | ||