Prevent infinite push loop between multiple directories
- Add auto increment id to sync-push-queue table to add new profile urls at the end - Use REPLACE instead of INSERT to prevent unique key errors
This commit is contained in:
parent
4de3fcf5f5
commit
9031423278
2 changed files with 6 additions and 4 deletions
|
@ -190,8 +190,10 @@ CREATE TABLE IF NOT EXISTS `sync-pull-queue` (
|
|||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sync-push-queue` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`url` varchar(255) CHARACTER SET utf8 NOT NULL,
|
||||
PRIMARY KEY (`url`)
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `url` (`url`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
|
|
@ -13,7 +13,7 @@ function sync_pull($url)
|
|||
|
||||
//If we support it that is.
|
||||
if ($a->config['syncing']['enable_pulling']) {
|
||||
q("INSERT INTO `sync-pull-queue` (`url`) VALUES ('%s')", dbesc($url));
|
||||
q("REPLACE INTO `sync-pull-queue` (`url`) VALUES ('%s')", dbesc($url));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ function sync_push($url)
|
|||
|
||||
//If we support it that is.
|
||||
if ($a->config['syncing']['enable_pushing']) {
|
||||
q("INSERT INTO `sync-push-queue` (`url`) VALUES ('%s')", dbesc($url));
|
||||
q("REPLACE INTO `sync-push-queue` (`url`) VALUES ('%s')", dbesc($url));
|
||||
}
|
||||
|
||||
sync_mark($url);
|
||||
|
@ -96,7 +96,7 @@ function get_push_targets()
|
|||
*/
|
||||
function get_push_batch(App $a)
|
||||
{
|
||||
return q("SELECT * FROM `sync-push-queue` LIMIT %u", intval($a->config['syncing']['max_push_items']));
|
||||
return q("SELECT * FROM `sync-push-queue` ORDER BY `id` LIMIT %u", intval($a->config['syncing']['max_push_items']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue