[PATCH cubicweb] Add a migration function in order to relocate bfss

Noé Gaumont noe.gaumont at logilab.fr
Wed Oct 16 17:52:13 CEST 2019


On 16/10/2019 17:03, Philippe Pepiot wrote:
> On 16/10/2019, noe.gaumont at logilab.fr wrote:
>> +class MigrationStorageCommandsTC(StorageTC, MigrationCommandsTC):
>> +
>> +    def test_change_bfss_path(self):
>> +        with self.mh() as (cnx, mh):
>> +            file1 = mh.cmd_create_entity('File', data_name=u"foo.pdf",
>> +                                         data=Binary(b"xxx"), data_format=u'text/plain')
>> +            mh.commit()
>> +            current_dir = osp.dirname(self.fspath(cnx, file1))
>> +
>> +            mh.update_bfss_path(current_dir, 'loutre', commit=True)
> It's not clear to me where the 'loutre' directory is located during
> tests. I guess in the current working directory ? In this case maybe a
> tempfile.mkdtemp() would be more suitable.

I think I misnamed the function and did not added enough documentation, 
because the purpose of this function is not to create any new file.
A use case could be:

- make sql dump of some remote instance
- copy the remote content of the bfss folder (e.g. /data/instance/photo) 
used to a local folder (e.g. /home/src/data/photo)

In this state, all the paths point to /data/instance/photo and generate 
errors at run time when using the instance.
The function update_bfss_path is intended to update the path stored but 
it does not check existence.

That is why this test is working, even if there is no loutre directory.


A solution might be to check the file exists in update_bfss_path before 
updating the path.
In this case, the test would be:

- create the file
- copy the file to another tempdir
-  update_bfss_path
- assert


Noé





More information about the cubicweb-devel mailing list