Software /
code /
prosody
Comparison
util/datamanager.lua @ 7996:f4c0fb54e16c
util.datamanager: Remove check for file non-existence since ENOENT tells us that already
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 22 Mar 2017 12:02:52 +0100 |
parent | 7995:b99404a340fc |
child | 8011:f8ba814fe029 |
comparison
equal
deleted
inserted
replaced
7995:b99404a340fc | 7996:f4c0fb54e16c |
---|---|
130 if not data then | 130 if not data then |
131 if errno == ENOENT then | 131 if errno == ENOENT then |
132 -- No such file, ok to ignore | 132 -- No such file, ok to ignore |
133 return nil; | 133 return nil; |
134 end | 134 end |
135 local mode = lfs.attributes(getpath(username, host, datastore), "mode"); | 135 log("error", "Failed to load %s storage ('%s') for user: %s@%s", datastore, err, username or "nil", host or "nil"); |
136 if not mode then | 136 return nil, "Error reading storage"; |
137 log("debug", "Assuming empty %s storage ('%s') for user: %s@%s", datastore, err, username or "nil", host or "nil"); | |
138 return nil; | |
139 else -- file exists, but can't be read | |
140 -- TODO more detailed error checking and logging? | |
141 log("error", "Failed to load %s storage ('%s') for user: %s@%s", datastore, err, username or "nil", host or "nil"); | |
142 return nil, "Error reading storage"; | |
143 end | |
144 end | 137 end |
145 | 138 |
146 local success, ret = pcall(data); | 139 local success, ret = pcall(data); |
147 if not success then | 140 if not success then |
148 log("error", "Unable to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil"); | 141 log("error", "Unable to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil"); |
304 if not data then | 297 if not data then |
305 if errno == ENOENT then | 298 if errno == ENOENT then |
306 -- No such file, ok to ignore | 299 -- No such file, ok to ignore |
307 return nil; | 300 return nil; |
308 end | 301 end |
309 local mode = lfs.attributes(getpath(username, host, datastore, "list"), "mode"); | 302 log("error", "Failed to load %s storage ('%s') for user: %s@%s", datastore, err, username or "nil", host or "nil"); |
310 if not mode then | 303 return nil, "Error reading storage"; |
311 log("debug", "Assuming empty %s storage ('%s') for user: %s@%s", datastore, err, username or "nil", host or "nil"); | |
312 return nil; | |
313 else -- file exists, but can't be read | |
314 -- TODO more detailed error checking and logging? | |
315 log("error", "Failed to load %s storage ('%s') for user: %s@%s", datastore, err, username or "nil", host or "nil"); | |
316 return nil, "Error reading storage"; | |
317 end | |
318 end | 304 end |
319 | 305 |
320 local success, ret = pcall(data); | 306 local success, ret = pcall(data); |
321 if not success then | 307 if not success then |
322 log("error", "Unable to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil"); | 308 log("error", "Unable to load %s storage ('%s') for user: %s@%s", datastore, ret, username or "nil", host or "nil"); |