Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peinhu committed Mar 28, 2019
1 parent e8d804f commit 64b07d0
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 226 deletions.
1 change: 0 additions & 1 deletion src/Console/ListGroupDirectoryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class ListGroupDirectoryCommand extends Command
*/
protected $description = 'List and create the directories for the groups';

protected $resourceHandler;

/**
* Create a new command instance.
Expand Down
32 changes: 16 additions & 16 deletions src/RedisSavedPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class RedisSavedPath
{

/**
* @param $resourceHash
* @param $key
* @return bool
*/
public static function exists($resourceHash)
public static function exists($key)
{
$result = Redis::hexists('aetherupload_resource', $resourceHash);
$result = Redis::hexists('aetherupload_resource', $key);

if ( $result !== 1 && $result !== 0 ) {
throw new \Exception('exists error');
Expand All @@ -23,12 +23,12 @@ public static function exists($resourceHash)
}

/**
* @param $resourceHash
* @param $key
* @return string
*/
public static function get($resourceHash)
public static function get($key)
{
$result = Redis::hget('aetherupload_resource', $resourceHash);
$result = Redis::hget('aetherupload_resource', $key);

if ( $result === null) {
throw new \Exception('read error');
Expand All @@ -39,13 +39,13 @@ public static function get($resourceHash)

/**
* set or overwrite a hash
* @param $resourceHash
* @param $key
* @param $savedPath
* @return bool
*/
public static function set($savedPathKey, $savedPath)
public static function set($key, $savedPath)
{
$result = Redis::hset('aetherupload_resource', $savedPathKey, $savedPath);
$result = Redis::hset('aetherupload_resource', $key, $savedPath);

if ( $result !== 0 && $result !== 1 ) {
throw new \Exception('write error');
Expand All @@ -55,23 +55,23 @@ public static function set($savedPathKey, $savedPath)
}

/**
* @param $resourceHashArr
* @param $keyArr
* @return bool
*/
public static function setMulti($resourceHashArr)
public static function setMulti($keyArr)
{
$result = Redis::hmset('aetherupload_resource', $resourceHashArr);
$result = Redis::hmset('aetherupload_resource', $keyArr);

return $result;
}

/**
* @param $resourceHash
* @param $key
* @return bool
*/
public static function delete($resourceHash)
public static function delete($key)
{
$result = Redis::hdel('aetherupload_resource', $resourceHash);
$result = Redis::hdel('aetherupload_resource', $key);

if ( $result !== 1 ) {
throw new \Exception('delete error');
Expand All @@ -88,4 +88,4 @@ public static function deleteAll()
}


}
}
4 changes: 2 additions & 2 deletions src/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class Resource
public $path;
public $realPath;

public function __construct($name, $groupSubDir)
public function __construct($group, $groupSubDir, $name)
{
$this->disk = Storage::disk('local');
$this->name = $name;
$this->group = ConfigMapper::get('group');
$this->group = $group;
$this->groupDir = ConfigMapper::get('group_dir');
$this->groupSubDir = $groupSubDir;
$this->path = $this->getPath();
Expand Down
6 changes: 3 additions & 3 deletions src/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function display($uri)

ConfigMapper::instance()->applyGroupConfig($group);

$resource = new Resource($resourceName, $groupSubDir);
$resource = new Resource($group, $groupSubDir, $resourceName);

if ( $resource->exists($resource->path) === false ) {
throw new \Exception;
Expand All @@ -41,7 +41,7 @@ public function download($uri, $newName = null)

ConfigMapper::instance()->applyGroupConfig($group);

$resource = new Resource($resourceName, $groupSubDir);
$resource = new Resource($group, $groupSubDir ,$resourceName);

if ( $resource->exists($resource->path) === false ) {
throw new \Exception;
Expand All @@ -58,4 +58,4 @@ public function download($uri, $newName = null)
}


}
}
Loading

0 comments on commit 64b07d0

Please sign in to comment.