Skip to content

Commit

Permalink
Fix delete call using public url and trying to get an invalid property
Browse files Browse the repository at this point in the history
  • Loading branch information
tystuyfzand committed Jun 10, 2018
1 parent 707e240 commit 6a08d74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/Model/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,29 @@ public function __construct($data) {
/**
* Pick a random volume location of the available locations.
*
* @return mixed
* @return Location
*/
public function getLocation() {
return $this->locations[array_rand($this->locations)];
}

/**
* Get the location's private url
* @return string
*/
public function getUrl() {
$location = $this->getLocation();

if (!$location) {
throw new \IllegalArgumentException('Unable to find a location to return.');
}

return $location->url;
}

/**
* Get the location's public url
* @return null
* @return string
*/
public function getPublicUrl() {
$location = $this->getLocation();
Expand Down
2 changes: 1 addition & 1 deletion src/SeaweedFS.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function delete($fid) {
throw new SeaweedFSException('Unable to find volume for ' . $fid);
}

$res = $this->client->delete($this->buildVolumeUrl($volume->publicUrl, $fid));
$res = $this->client->delete($this->buildVolumeUrl($volume->getUrl(), $fid));

if ($res->getStatusCode() != 202) {
throw new SeaweedFSException('Unexpected response when deleting file: ' . $res->getStatusCode());
Expand Down

0 comments on commit 6a08d74

Please sign in to comment.