Add mutex on datastore I/O operations
To make sure that there is no concurrent operation on the datastore file. Fixes #1132
This commit is contained in:
parent
458b6b9918
commit
fd1ddad98d
26 changed files with 218 additions and 63 deletions
tests/netscape
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Shaarli\Netscape;
|
||||
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
use Shaarli\Bookmark\BookmarkFileService;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Formatter\BookmarkFormatter;
|
||||
|
@ -56,12 +57,13 @@ class BookmarkExportTest extends TestCase
|
|||
*/
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$mutex = new NoMutex();
|
||||
static::$conf = new ConfigManager('tests/utils/config/configJson');
|
||||
static::$conf->set('resource.datastore', static::$testDatastore);
|
||||
static::$refDb = new \ReferenceLinkDB();
|
||||
static::$refDb->write(static::$testDatastore);
|
||||
static::$history = new History('sandbox/history.php');
|
||||
static::$bookmarkService = new BookmarkFileService(static::$conf, static::$history, true);
|
||||
static::$bookmarkService = new BookmarkFileService(static::$conf, static::$history, $mutex, true);
|
||||
$factory = new FormatterFactory(static::$conf, true);
|
||||
static::$formatter = $factory->getFormatter('raw');
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Shaarli\Netscape;
|
||||
|
||||
use DateTime;
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\BookmarkFileService;
|
||||
|
@ -87,6 +88,7 @@ class BookmarkImportTest extends TestCase
|
|||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$mutex = new NoMutex();
|
||||
if (file_exists(self::$testDatastore)) {
|
||||
unlink(self::$testDatastore);
|
||||
}
|
||||
|
@ -97,7 +99,7 @@ class BookmarkImportTest extends TestCase
|
|||
$this->conf->set('resource.page_cache', $this->pagecache);
|
||||
$this->conf->set('resource.datastore', self::$testDatastore);
|
||||
$this->history = new History(self::$historyFilePath);
|
||||
$this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true);
|
||||
$this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true);
|
||||
$this->netscapeBookmarkUtils = new NetscapeBookmarkUtils($this->bookmarkService, $this->conf, $this->history);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue