Mercurial > prosody-modules
comparison mod_migrate_http_upload/mod_migrate_http_upload.lua @ 4470:203f0f06d766
mod_migrate_http_upload: Respect the 'http_upload_path' setting
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Feb 2021 18:12:12 +0100 |
parents | 5d8f9cc5c6fb |
children | af7a9856950d |
comparison
equal
deleted
inserted
replaced
4469:6844733ad2f5 | 4470:203f0f06d766 |
---|---|
16 | 16 |
17 sm.initialize_host(component); | 17 sm.initialize_host(component); |
18 | 18 |
19 local new_uploads = sm.open(component, "uploads", "archive"); | 19 local new_uploads = sm.open(component, "uploads", "archive"); |
20 | 20 |
21 local legacy_storage_path = module:context(component):get_option_string("http_upload_path", paths.join(prosody.paths.data, "http_upload")); | |
22 | |
21 local legacy_uploads = {}; | 23 local legacy_uploads = {}; |
22 for user in assert(dm.users(user_host, "http_upload", "list")) do | 24 for user in assert(dm.users(user_host, "http_upload", "list")) do |
23 legacy_uploads[user] = dm.list_load(user, user_host, "http_upload"); | 25 legacy_uploads[user] = dm.list_load(user, user_host, "http_upload"); |
24 end | 26 end |
25 while true do | 27 while true do |
29 oldest_uploads, uploader = uploads, jid.join(user, user_host); | 31 oldest_uploads, uploader = uploads, jid.join(user, user_host); |
30 end | 32 end |
31 end | 33 end |
32 if not oldest_uploads then break end | 34 if not oldest_uploads then break end |
33 local item = table.remove(oldest_uploads, 1); | 35 local item = table.remove(oldest_uploads, 1); |
34 local source_directory = paths.join(prosody.paths.data, "http_upload", item.dir); | 36 local source_directory = paths.join(legacy_storage_path, item.dir); |
35 local source_filename = paths.join(prosody.paths.data, "http_upload", item.dir, item.filename); | 37 local source_filename = paths.join(source_directory, item.dir, item.filename); |
36 local target_filename = dm.getpath(item.dir, component, "http_file_share", "bin", true); | 38 local target_filename = dm.getpath(item.dir, component, "http_file_share", "bin", true); |
37 if not lfs.attributes(source_filename, "mode") then | 39 if not lfs.attributes(source_filename, "mode") then |
38 print("Not migrating missing file " .. source_filename); | 40 print("Not migrating missing file " .. source_filename); |
39 else | 41 else |
40 print("Moving " .. source_filename .. " to " .. target_filename .. " for " .. uploader); | 42 print("Moving " .. source_filename .. " to " .. target_filename .. " for " .. uploader); |