mirror of
https://github.com/Chouchen/Shikiryu_Backup.git
synced 2021-06-30 16:02:14 +02:00
✨ Makes dropbox working again
Using a new SDK, since the one we used is now deprecated
This commit is contained in:
@@ -9,7 +9,6 @@ use Shikiryu\Backup\Transport\Factory as TransportFactory;
|
||||
|
||||
class Scenario
|
||||
{
|
||||
|
||||
/* @var $backup BackupAbstract */
|
||||
private $backup;
|
||||
/* @var $to TransportAbstract */
|
||||
@@ -18,19 +17,8 @@ class Scenario
|
||||
public static function register()
|
||||
{
|
||||
include __DIR__.'/../../vendor/autoload.php';
|
||||
//spl_autoload_register(array(__CLASS__, 'autoload'));
|
||||
}
|
||||
|
||||
/*public static function autoload($class)
|
||||
{
|
||||
if (strpos($class, __NAMESPACE__.'\\') === 0)
|
||||
{
|
||||
$relative_NS = str_replace(__NAMESPACE__, '', $class);
|
||||
$translated_path = str_replace('\\', '/', $relative_NS);
|
||||
require __DIR__ . '/' . $translated_path . '.php';
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @param array $scenario
|
||||
*/
|
||||
@@ -70,8 +58,6 @@ class Scenario
|
||||
// add autoloader
|
||||
static::register();
|
||||
|
||||
$scenario = __DIR__.'/../scenario/'.$scenario;
|
||||
|
||||
// check the given scenario
|
||||
if (is_readable($scenario)) {
|
||||
$scenario = json_decode(file_get_contents($scenario), true);
|
||||
|
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace Shikiryu\Backup\Transport;
|
||||
|
||||
use Dropbox\Client;
|
||||
use Shikiryu\Backup\Transport\TransportAbstract;
|
||||
use Spatie\Dropbox\Client;
|
||||
|
||||
class Dropbox extends TransportAbstract
|
||||
{
|
||||
@@ -15,13 +14,13 @@ class Dropbox extends TransportAbstract
|
||||
private $dropbox;
|
||||
|
||||
protected $token = '';
|
||||
protected $app = '';
|
||||
// protected $app = '';
|
||||
protected $folder = '';
|
||||
|
||||
public function __construct($backup, $config)
|
||||
{
|
||||
parent::__construct($backup, $config);
|
||||
$this->dropbox = new Client($this->token, $this->app);
|
||||
$this->dropbox = new Client($this->token);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +32,7 @@ class Dropbox extends TransportAbstract
|
||||
$files = $this->backup->getFilesToBackup();
|
||||
foreach ($files as $file => $name) {
|
||||
$file = fopen($file, 'rb');
|
||||
$upload = $this->dropbox->uploadFile($this->folder.'/'.$name, \Dropbox\WriteMode::force(), $file);
|
||||
$upload = $this->dropbox->upload($this->folder.'/'.$name, $file);
|
||||
if (!$upload) {
|
||||
$sent = false;
|
||||
echo 'DROPBOX upload manqu<71>e de '.$file.' vers '.$this->folder.$name;
|
||||
@@ -41,11 +40,7 @@ class Dropbox extends TransportAbstract
|
||||
}
|
||||
$streams = $this->backup->getStreamsToBackup();
|
||||
foreach ($streams as $stream => $name) {
|
||||
$upload = $this->dropbox->uploadFileFromString(
|
||||
$this->folder . '/' . $name,
|
||||
\Dropbox\WriteMode::force(),
|
||||
$stream
|
||||
);
|
||||
$upload = $this->dropbox->upload($this->folder . '/' . $name, $stream);
|
||||
if (!$upload) {
|
||||
$sent = false;
|
||||
echo 'DROPBOX upload manquée de ' . $file . ' vers '.$this->folder.$name;
|
||||
|
@@ -3,7 +3,6 @@ namespace Shikiryu\Backup\Backup;
|
||||
|
||||
class Files extends BackupAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @throws \Exception
|
||||
|
Reference in New Issue
Block a user