diff options
author | Robin Appelman <robin@icewind.nl> | 2018-12-12 15:24:40 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-12-12 15:24:40 +0100 |
commit | d6bf5d43841f8d80ed54137db75c8ca6d2396cf4 (patch) | |
tree | ebd0520e813236fa005ec9fe49e1b04c3544a03d /tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php | |
parent | 6c9f2644cf8bac151b9af743802eb72a51278e8b (diff) | |
download | nextcloud-server-d6bf5d43841f8d80ed54137db75c8ca6d2396cf4.tar.gz nextcloud-server-d6bf5d43841f8d80ed54137db75c8ca6d2396cf4.zip |
upload new files in objectstore to a .part path first
This prevent the object store and cache from getting out of sync
when an objectstore silently fails or the php process get's killed
during the upload without giving us the chance to cleanup
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php')
-rw-r--r-- | tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php index c9d6c1bd922..3b3827f460a 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php @@ -30,6 +30,8 @@ use Test\Files\Storage\Storage; * @group DB */ class ObjectStoreStorageTest extends Storage { + /** @var ObjectStoreStorageOverwrite */ + protected $instance; /** * @var IObjectStore @@ -42,7 +44,7 @@ class ObjectStoreStorageTest extends Storage { $baseStorage = new Temporary(); $this->objectStorage = new StorageObjectStore($baseStorage); $config['objectstore'] = $this->objectStorage; - $this->instance = new ObjectStoreStorage($config); + $this->instance = new ObjectStoreStorageOverwrite($config); } protected function tearDown() { @@ -166,4 +168,17 @@ class ObjectStoreStorageTest extends Storage { $targetId = $this->instance->getCache()->getId('target'); $this->assertSame($sourceId, $targetId, 'fileid must be stable on move or shares will break'); } + + public function testWriteObjectSilentFailure() { + $objectStore = $this->instance->getObjectStore(); + $this->instance->setObjectStore(new FailWriteObjectStore($objectStore)); + + try { + $this->instance->file_put_contents('test.txt', 'foo'); + $this->fail('expected exception'); + } catch (\Exception $e) { + $this->assertStringStartsWith('Object not found after writing', $e->getMessage()); + } + $this->assertFalse($this->instance->file_exists('test.txt')); + } } |