Open-Telecoms-Data / cove-ofds

https://ofds.cove.opendataservices.coop/
Other
1 stars 0 forks source link

libcoveweb2: Change location of where supplied data is saved #93

Closed odscjames closed 1 year ago

odscjames commented 1 year ago

Makes sure files are served with original file name - this requirement was discussed elsewhere - while making sure there can be no problems with 2 files having the same name.

odscjames commented 1 year ago

This comes with a python script to run in the media dir on deploy:


import os

for name in os.listdir('.'):
    if os.path.isdir(name):
        for old_file_name in os.listdir(os.path.join(name, "supplied_data")):
            if os.path.isfile(os.path.join(name, "supplied_data", old_file_name)):
                file_id = old_file_name[0:36]
                new_file_name = old_file_name[37:]
                os.mkdir(os.path.join(name, "supplied_data", file_id))
                os.rename(
                    os.path.join(name, "supplied_data", old_file_name),
                    os.path.join(name, "supplied_data", file_id, new_file_name)
                )