Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ larger packet size to be sent in a query. To do this, add the following line to
your SQL config file:

[mysqld]
max_allowed_pack = 512M
max_allowed_packet = 512M

You don't have to use 512MB as your packet size, but anything 16MB or higher is
advised.
Expand Down
2 changes: 1 addition & 1 deletion sync/config/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ yahoo[port] = 993
yahoo[smtp_host] = "imap.mail.yahoo.com"
yahoo[smtp_port] = "smtp.mail.yahoo.com"
other[port] = 993
other[smtp_port] = 993
other[smtp_port] = 587
attachments[path] = "attachments"

[daemon]
Expand Down
7 changes: 7 additions & 0 deletions sync/src/Console/SyncConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SyncConsole extends Console
public $sleep;
public $create;
public $folder;
public $email;
public $daemon;
public $actions;
public $verbose;
Expand Down Expand Up @@ -81,6 +82,11 @@ protected function setupArgs()
'longPrefix' => 'folder',
'description' => 'Sync the selected folder'
],
'email' => [
'prefix' => 'm',
'longPrefix' => 'email',
'description' => 'Sync the selected email account (passing email)'
],
'help' => [
'prefix' => 'h',
'longPrefix' => 'help',
Expand Down Expand Up @@ -163,6 +169,7 @@ protected function parseArgs()
$this->diagnostics = $this->cli->arguments->get('diagnostics');
$this->interactive = $this->cli->arguments->get('interactive');
$this->databaseExists = $this->cli->arguments->get('exists');
$this->email = $this->cli->arguments->get('email');

// Some flags also enable interactive mode
if (true === $this->sleep
Expand Down
23 changes: 21 additions & 2 deletions sync/src/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Sync
private $maxRetries = 5;
private $retriesFolders;
private $retriesMessages;
private $email;

// Config
const READY_THRESHOLD = 60;
Expand Down Expand Up @@ -99,6 +100,7 @@ public function __construct(Container $di = null)
$this->quick = $di['console']->quick;
$this->sleep = $di['console']->sleep;
$this->folder = $di['console']->folder;
$this->email = $di['console']->email;
$this->daemon = $di['console']->daemon;
$this->actions = $di['console']->actions;
$this->threading = $di['console']->threading;
Expand All @@ -108,6 +110,22 @@ public function __construct(Container $di = null)
$this->initGc();
}

/**
* @return mixed
*/
public function getEmail()
{
return $this->email;
}

/**
* @param mixed $email
*/
public function setEmail($email)
{
$this->email = $email;
}

/**
* @param CLImate $cli
*/
Expand Down Expand Up @@ -141,6 +159,7 @@ public function loop()
{
$wakeUnix = 0;
$sleepMinutes = $this->config['app']['sync']['sleep_minutes'];
$account = ((new AccountModel)->getByEmail($this->email)) ?: null;

while (true) {
$this->gc();
Expand All @@ -155,7 +174,7 @@ public function loop()
// Run action sync every minute
if ($this->isReadyToRun()) {
$this->setAsleep(false);
$this->run(null, [self::OPT_ONLY_SYNC_ACTIONS => true]);
$this->run($account, [self::OPT_ONLY_SYNC_ACTIONS => true]);
$this->setAsleep(true);
}

Expand All @@ -165,7 +184,7 @@ public function loop()

$this->setAsleep(false);

if (! $this->run()) {
if (! $this->run($account)) {
throw new TerminateException('Sync was prevented from running');
}

Expand Down