Skip to content

Commit

Permalink
Improve factory definition to match core
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell committed Dec 7, 2021
1 parent e0e0fd2 commit 8e7d429
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Model/File/Storage/Synchronization.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Synchronization
/**
* @var BucketFactory
*/
protected $bucket;
protected $storageFactory;

/**
* File stream handler
Expand All @@ -20,11 +20,11 @@ class Synchronization
protected $mediaDirectory;

public function __construct(
DirectoryWrite $directory,
BucketFactory $bucket
BucketFactory $storageFactory,
DirectoryWrite $directory
) {
$this->storageFactory = $storageFactory;
$this->mediaDirectory = $directory;
$this->bucket = $bucket;
}

/**
Expand All @@ -35,9 +35,14 @@ public function __construct(
*/
public function synchronize($relativeFileName)
{
$storage = $this->bucket->loadByFilename($relativeFileName);

/** @var $storage Bucket */
$storage = $this->storageFactory->create();
try {
$storage->loadByFilename($relativeFileName);
} catch (\Exception $e) {
}
if ($storage->getId()) {
/** @var WriteInterface $file */
$file = $this->mediaDirectory->openFile($relativeFileName, 'w');
try {
$file->lock();
Expand Down

0 comments on commit 8e7d429

Please sign in to comment.