mod_migrate: Log read and write errors instead of raising error

Mon, 07 Mar 2016 12:44:29 +0100

author
Kim Alvefur <zash@zash.se>
date
Mon, 07 Mar 2016 12:44:29 +0100
changeset 2064
2a82c55762a7
parent 2063
6055a0164d63
child 2065
624e3fed6f92

mod_migrate: Log read and write errors instead of raising error

mod_migrate/mod_migrate.lua file | annotate | diff | comparison | revisions
--- a/mod_migrate/mod_migrate.lua	Mon Mar 07 11:15:28 2016 +0100
+++ b/mod_migrate/mod_migrate.lua	Mon Mar 07 12:44:29 2016 +0100
@@ -24,8 +24,14 @@
 		local function migrate_user(username)
 			module:log("info", "Migrating %s data for %s", source_store, username);
 			local data, err = storage:get(username);
-			assert(data or err==nil, err);
-			assert(target:set(username, data));
+			if not data and err then
+				module:log("error", "Could not read data: %s", err);
+			else
+				local ok, err = target:set(username, data);
+				if not ok then
+					module:log("error", "Could not write data: %s", err);
+				end
+			end
 		end
 
 		if store_type == "archive" then

mercurial