Skip to content

Commit

Permalink
Corrupted path detected pionl#143
Browse files Browse the repository at this point in the history
  • Loading branch information
Janith-Umeda committed Jun 7, 2024
1 parent cfbc429 commit f81e78f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/chunk-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'use' => [
'session' => true, // should the chunk name use the session id? The uploader must send cookie!,
'browser' => false, // instead of session we can use the ip and browser?
'hashName' => false // use a hash name instead of the original file name
],
],
],
Expand Down
11 changes: 8 additions & 3 deletions src/Commands/ClearChunksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Str;
use Pion\Laravel\ChunkUpload\ChunkFile;
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;
use RuntimeException;
use Symfony\Component\Console\Output\OutputInterface;

class ClearChunksCommand extends Command
Expand Down Expand Up @@ -51,9 +52,13 @@ public function handle(ChunkStorage $storage)
$this->comment('> '.$file, $verbouse);

// delete the file
if ($file->delete()) {
++$deleted;
} else {
try{
if ($file->delete()) {
++$deleted;
} else {
$this->error('> chunk not deleted: '.$file);
}
}catch(RuntimeException $err){
$this->error('> chunk not deleted: '.$file);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/Config/AbstractConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ abstract public function chunkUseSessionForName();
* @return bool
*/
abstract public function chunkUseBrowserInfoForName();

/**
* Should the chunk name add a hash name instead of original file name?
*
* @return bool
*/
abstract public function chunkUseHashNameForName();
}
10 changes: 10 additions & 0 deletions src/Config/FileConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public function chunkUseBrowserInfoForName()
return $this->get('chunk.name.use.browser', false);
}

/**
* Should the chunk name add a hash name instead of original file name?
*
* @return bool
*/
public function chunkUseHashNameForName()
{
return $this->get('chunk.name.use.hashName', false);
}

/**
* Returns a chunks config value.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function createChunkFileName($additionalName = null, $currentChunkIndex =
{
// prepare basic name structure
$array = [
$this->file->getClientOriginalName(),
$this->config->chunkUseHashNameForName() ? md5($this->file->getClientOriginalName()) : $this->file->getClientOriginalName(),
];

// ensure that the chunk name is for unique for the client session
Expand Down

0 comments on commit f81e78f

Please sign in to comment.