Mercurial > prosody-modules
comparison mod_migrate/mod_migrate.lua @ 3584:611ac62c5b63
mod_migrate: Try to use per storage user listing where available
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 05 May 2019 16:04:20 +0200 |
| parents | cd9831b27746 |
| children | c9e1eee6a948 |
comparison
equal
deleted
inserted
replaced
| 3583:a36412d4fafd | 3584:611ac62c5b63 |
|---|---|
| 1 -- mod_migrate | 1 -- mod_migrate |
| 2 | 2 |
| 3 local unpack = table.unpack or unpack; | |
| 3 local sm = require"core.storagemanager"; | 4 local sm = require"core.storagemanager"; |
| 4 local um = require"core.usermanager"; | 5 local um = require"core.usermanager"; |
| 6 | |
| 7 local function users(store, host) | |
| 8 if store.users then | |
| 9 return store:users(); | |
| 10 else | |
| 11 return um.users(host); | |
| 12 end | |
| 13 end | |
| 5 | 14 |
| 6 function module.command(arg) | 15 function module.command(arg) |
| 7 local host, source_stores, migrate_to = unpack(arg); | 16 local host, source_stores, migrate_to = unpack(arg); |
| 8 if not migrate_to then | 17 if not migrate_to then |
| 9 return print("Usage: prosodyctl mod_migrate example.com <source-store>[-<store-type>] <target-driver> [users]*"); | 18 return print("Usage: prosodyctl mod_migrate example.com <source-store>[-<store-type>] <target-driver> [users]*"); |
| 60 for i = 4, #arg do | 69 for i = 4, #arg do |
| 61 migrate_user(arg[i]); | 70 migrate_user(arg[i]); |
| 62 end | 71 end |
| 63 else | 72 else |
| 64 xpcall(function() | 73 xpcall(function() |
| 65 for user in um.users(host) do | 74 for user in users(storage, host) do |
| 66 migrate_user(user); | 75 migrate_user(user); |
| 67 end | 76 end |
| 68 end, | 77 end, |
| 69 function (err) | 78 function (err) |
| 70 module:log("error", "Could not list users, you'll have to supply them as arguments"); | 79 module:log("error", "Could not list users, you'll have to supply them as arguments"); |
