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

Philippe Pepiot philippe.pepiot at logilab.fr
Thu Oct 17 10:34:20 CEST 2019


On 16/10/2019, NoƩ Gaumont wrote:
> 
> 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.

Oh I see, it's not about moving files but just updating their path in
database, which is actually more often useful.

The patch LGTM then



More information about the cubicweb-devel mailing list