Mercurial > prosody-modules
comparison mod_migrate/mod_migrate.lua @ 2064:2a82c55762a7
mod_migrate: Log read and write errors instead of raising error
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 07 Mar 2016 12:44:29 +0100 |
parents | 530bf8ef2e55 |
children | 17408ddd34b0 |
comparison
equal
deleted
inserted
replaced
2063:6055a0164d63 | 2064:2a82c55762a7 |
---|---|
22 target = assert(target:open(source_store, store_type)); | 22 target = assert(target:open(source_store, store_type)); |
23 | 23 |
24 local function migrate_user(username) | 24 local function migrate_user(username) |
25 module:log("info", "Migrating %s data for %s", source_store, username); | 25 module:log("info", "Migrating %s data for %s", source_store, username); |
26 local data, err = storage:get(username); | 26 local data, err = storage:get(username); |
27 assert(data or err==nil, err); | 27 if not data and err then |
28 assert(target:set(username, data)); | 28 module:log("error", "Could not read data: %s", err); |
29 else | |
30 local ok, err = target:set(username, data); | |
31 if not ok then | |
32 module:log("error", "Could not write data: %s", err); | |
33 end | |
34 end | |
29 end | 35 end |
30 | 36 |
31 if store_type == "archive" then | 37 if store_type == "archive" then |
32 function migrate_user(username) | 38 function migrate_user(username) |
33 module:log("info", "Migrating %s archive items for %s", source_store, username); | 39 module:log("info", "Migrating %s archive items for %s", source_store, username); |