Software /
code /
prosody
Annotate
tools/migration/migrator/prosody_files.lua @ 4513:23b540ab346a
core.s2smanager: Log the entire stream header.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 04 Mar 2012 17:38:47 +0100 |
parent | 4293:419354c47c28 |
child | 5021:85b2689dbcfe |
rev | line source |
---|---|
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
1 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
2 local print = print; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
3 local assert = assert; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
4 local setmetatable = setmetatable; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
5 local tonumber = tonumber; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
6 local char = string.char; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
7 local coroutine = coroutine; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
8 local lfs = require "lfs"; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
9 local loadfile = loadfile; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
10 local setfenv = setfenv; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
11 local pcall = pcall; |
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
12 local mtools = require "migrator.mtools"; |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
13 local next = next; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
14 local pairs = pairs; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
15 local json = require "util.json"; |
4241
49b9e73e31ef
tools/migration/migrator/prosody_files.lua: Fix for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
4239
diff
changeset
|
16 local os_getenv = os.getenv; |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
17 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
18 prosody = {}; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
19 local dm = require "util.datamanager" |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
20 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
21 module "prosody_files" |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
22 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
23 local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
24 local function is_file(path) return lfs.attributes(path, "mode") == "file"; end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
25 local function clean_path(path) |
4241
49b9e73e31ef
tools/migration/migrator/prosody_files.lua: Fix for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
4239
diff
changeset
|
26 return path:gsub("\\", "/"):gsub("//+", "/"):gsub("^~", os_getenv("HOME") or "~"); |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
27 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
28 local encode, decode; do |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
29 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
30 decode = function (s) return s and (s:gsub("+", " "):gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
31 encode = function (s) return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
32 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
33 local function decode_dir(x) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
34 if x:gsub("%%%x%x", ""):gsub("[a-zA-Z0-9]", "") == "" then |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
35 return decode(x); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
36 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
37 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
38 local function decode_file(x) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
39 if x:match(".%.dat$") and x:gsub("%.dat$", ""):gsub("%%%x%x", ""):gsub("[a-zA-Z0-9]", "") == "" then |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
40 return decode(x:gsub("%.dat$", "")); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
41 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
42 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
43 local function prosody_dir(path, ondir, onfile, ...) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
44 for x in lfs.dir(path) do |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
45 local xpath = path.."/"..x; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
46 if decode_dir(x) and is_dir(xpath) then |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
47 ondir(xpath, x, ...); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
48 elseif decode_file(x) and is_file(xpath) then |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
49 onfile(xpath, x, ...); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
50 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
51 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
52 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
53 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
54 local function handle_root_file(path, name) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
55 --print("root file: ", decode_file(name)) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
56 coroutine.yield { user = nil, host = nil, store = decode_file(name) }; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
57 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
58 local function handle_host_file(path, name, host) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
59 --print("host file: ", decode_dir(host).."/"..decode_file(name)) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
60 coroutine.yield { user = nil, host = decode_dir(host), store = decode_file(name) }; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
61 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
62 local function handle_store_file(path, name, store, host) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
63 --print("store file: ", decode_file(name).."@"..decode_dir(host).."/"..decode_dir(store)) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
64 coroutine.yield { user = decode_file(name), host = decode_dir(host), store = decode_dir(store) }; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
65 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
66 local function handle_host_store(path, name, host) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
67 prosody_dir(path, function() end, handle_store_file, name, host); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
68 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
69 local function handle_host_dir(path, name) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
70 prosody_dir(path, handle_host_store, handle_host_file, name); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
71 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
72 local function handle_root_dir(path) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
73 prosody_dir(path, handle_host_dir, handle_root_file); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
74 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
75 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
76 local function decode_user(item) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
77 local userdata = { |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
78 user = item[1].user; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
79 host = item[1].host; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
80 stores = {}; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
81 }; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
82 for i=1,#item do -- loop over stores |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
83 local result = {}; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
84 local store = item[i]; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
85 userdata.stores[store.store] = store.data; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
86 store.user = nil; store.host = nil; store.store = nil; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
87 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
88 return userdata; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
89 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
90 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
91 function reader(input) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
92 local path = clean_path(assert(input.path, "no input.path specified")); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
93 assert(is_dir(path), "input.path is not a directory"); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
94 local iter = coroutine.wrap(function()handle_root_dir(path);end); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
95 -- get per-user stores, sorted |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
96 local iter = mtools.sorted { |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
97 reader = function() |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
98 local x = iter(); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
99 if x then |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
100 dm.set_data_path(path); |
4293
419354c47c28
migrator/prosody_files: Don't choke on empty data stores for a user (thanks @eoranged)
Matthew Wild <mwild1@gmail.com>
parents:
4241
diff
changeset
|
101 local err; |
419354c47c28
migrator/prosody_files: Don't choke on empty data stores for a user (thanks @eoranged)
Matthew Wild <mwild1@gmail.com>
parents:
4241
diff
changeset
|
102 x.data, err = dm.load(x.user, x.host, x.store); |
419354c47c28
migrator/prosody_files: Don't choke on empty data stores for a user (thanks @eoranged)
Matthew Wild <mwild1@gmail.com>
parents:
4241
diff
changeset
|
103 if x.data == nil and err then |
419354c47c28
migrator/prosody_files: Don't choke on empty data stores for a user (thanks @eoranged)
Matthew Wild <mwild1@gmail.com>
parents:
4241
diff
changeset
|
104 error(("Error loading data at path %s for %s@%s (%s store)") |
419354c47c28
migrator/prosody_files: Don't choke on empty data stores for a user (thanks @eoranged)
Matthew Wild <mwild1@gmail.com>
parents:
4241
diff
changeset
|
105 :format(path, x.user or "<nil>", x.host or "<nil>", x.store or "<nil>"), 0); |
419354c47c28
migrator/prosody_files: Don't choke on empty data stores for a user (thanks @eoranged)
Matthew Wild <mwild1@gmail.com>
parents:
4241
diff
changeset
|
106 end |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
107 return x; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
108 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
109 end; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
110 sorter = function(a, b) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
111 local a_host, a_user, a_store = a.host or "", a.user or "", a.store or ""; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
112 local b_host, b_user, b_store = b.host or "", b.user or "", b.store or ""; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
113 return a_host > b_host or (a_host==b_host and a_user > b_user) or (a_host==b_host and a_user==b_user and a_store > b_store); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
114 end; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
115 }; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
116 -- merge stores to get users |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
117 iter = mtools.merged(iter, function(a, b) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
118 return (a.host == b.host and a.user == b.user); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
119 end); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
120 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
121 return function() |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
122 local x = iter(); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
123 return x and decode_user(x); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
124 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
125 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
126 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
127 function writer(output) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
128 local path = clean_path(assert(output.path, "no output.path specified")); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
129 assert(is_dir(path), "output.path is not a directory"); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
130 return function(item) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
131 if not item then return; end -- end of input |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
132 dm.set_data_path(path); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
133 for store, data in pairs(item.stores) do |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
134 assert(dm.store(item.user, item.host, store, data)); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
135 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
136 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
137 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
138 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
139 return _M; |