Internal permalink disappears after updating block field programmatically

Hi,
I am importing a (formerly) Wordpress blog into Kirby, and as part of the import process I am creating a blocks field-based content with links to attachments found in the original post. My goal is that the files will be included as $files in my $page object, so after creating the page initially, I scan the blocks field for possible links, then I $page->createFile() and it all goes well. The issue starts when I try to update the original href in the link to a local permalink (the //@/file/cxpCYrB6P6m4TR5T thingy). I create the new blocks object programmatically and then when I update the post the link that I fed with the permalink turns to an empty (<a></a>) link. I suspect Kirby filters out the link because the URL looks funny. Am I right? Do you know how I can get this link to update properly?
I will appreciate any help. Thanks!