How do I remove a file container or even a file?

I’ve got the following file:

[folaht@pjehrsohmehj safe]$ safe cat safe://hyryyry4uhxmkyzuraf8go4t6j3w99k5buf3rc7yy873ktgr4awdk7njojhnra
Files of FilesContainer (version 0) at "safe://hyryyry4uhxmkyzuraf8go4t6j3w99k5buf3rc7yy873ktgr4awdk7njojhnra":
+--------------+------------+------+----------------------+----------------------+--------------------------------------------------------------------+
| Name         | Type       | Size | Created              | Modified             | Link                                                               |
+--------------+------------+------+----------------------+----------------------+--------------------------------------------------------------------+
| /esjehks.txt | text/plain | 9    | 2021-01-31T23:52:28Z | 2021-01-31T23:52:28Z | safe://hy8oycypiop6bqnsnr5j5xda3ejsbb5hqi5u1ubq3prr9y7p83p1pgmbdga |
+--------------+------------+------+----------------------+----------------------+--------------------------------------------------------------------+

It’s the wrong filename, so I’ve tried removing it, but it doesn’t seem to work.

[folaht@pjehrsohmehj safe]$ safe files rm safe://hy8oycypiop6bqnsnr5j5xda3ejsbb5hqi5u1ubq3prr9y7p83p1pgmbdga/esjehks.txt
[2021-02-01T00:14:12Z ERROR safe] sn_cli error: [Error] ContentError - Cannot get relative path of Immutable Data "/esjehks.txt"
[folaht@pjehrsohmehj safe]$ safe files rm safe://hyryyry4uhxmkyzuraf8go4t6j3w99k5buf3rc7yy873ktgr4awdk7njojhnra/
[2021-02-01T00:15:44Z ERROR safe] sn_cli error: [Error] InvalidInput - The destination URL should include a target file path
[folaht@pjehrsohmehj safe]$ safe files rm safe://hyryyry4uhxmkyzuraf8go4t6j3w99k5buf3rc7yy873ktgr4awdk7njojhnra/esjehks.txt
[2021-02-01T00:28:46Z ERROR safe] sn_cli error: [Error] NetDataError - Failed to append to Sequence: NetworkDataError(InvalidSignature)
2 Likes
  • first command: you pass link to file instead of file container => error is normal
  • second command: you omit file name => error is normal
  • third command: syntax seems OK => it should have worked, so I don’t explain this one!

Working example:

$ safe cat safe://hyryyry651mqkzmdqcguxcrk8g8smzyrhhrbthy8t88ihzfsxdfag4bzgmcnra
Files of FilesContainer (version 0) at "safe://hyryyry651mqkzmdqcguxcrk8g8smzyrhhrbthy8t88ihzfsxdfag4bzgmcnra":
+-------------+-----------+------+----------------------+----------------------+--------------------------------------------------------------------+
| Name        | Type      | Size | Created              | Modified             | Link                                                               |
+-------------+-----------+------+----------------------+----------------------+--------------------------------------------------------------------+
| /index.html | text/html | 639  | 2021-01-29T08:18:10Z | 2021-01-29T08:18:10Z | safe://hy8oyryeurq5hcoqzyp5quj19azf3s5xtx5mfm4beu3at3gj6b5c3iwu4pc |
+-------------+-----------+------+----------------------+----------------------+--------------------------------------------------------------------+

$ safe files rm safe://hyryyry651mqkzmdqcguxcrk8g8smzyrhhrbthy8t88ihzfsxdfag4bzgmcnra/index.html
FilesContainer updated (version 1): "safe://hyryyry651mqkzmdqcguxcrk8g8smzyrhhrbthy8t88ihzfsxdfag4bzgmcnra?v=1"
-  /index.html  safe://hy8oyryeurq5hcoqzyp5quj19azf3s5xtx5mfm4beu3at3gj6b5c3iwu4pc

$ safe cat safe://hyryyry651mqkzmdqcguxcrk8g8smzyrhhrbthy8t88ihzfsxdfag4bzgmcnra
Files of FilesContainer (version 1) at "safe://hyryyry651mqkzmdqcguxcrk8g8smzyrhhrbthy8t88ihzfsxdfag4bzgmcnra":
+------+------+------+---------+----------+------+
| Name | Type | Size | Created | Modified | Link |
+------+------+------+---------+----------+------+
1 Like

Another thing to add: you cannot delete a file container because this would go against permanent web.

When you delete a file you don’t really delete it. Instead you create a new version of the file container that doesn’t contain the file anymore. But previous version still contains it which allows versioned references to work.

Deleting a file container would break all this.

2 Likes

Thanks for clearing that up.
Though that raises new questions.
If file containers are not deleted, but forgotten, doesn’t that create a lot of junk data?
Is there a way to retrieve a forgotten file container address that is devoid of files?
Is there a way to retrieve a forgotten file container address of which I know a file address of?
Is there a way to retrieve a forgotten file container address of which I know a file name of?

Perhaps you were trying to remove the file without self-authorising the CLI with the same Safe you used to upload the files on that FilesContainer?

3 Likes

That should be it.

Isn’t it only about public data? By my knowledge, all private data can be deleted.

Yes, but file containers are public data.

At the application level, file containers are Ad hoc structures managed by safe cli and safe browser. At the network level, they are stored as public blob (= public data in sn_data_types) which cannot be deleted.

1 Like

At the moment CLI and the API only supports creating public FilesContainers, but moving forward, I think we will be able to create private FilesContainers, they could be deleted as long as the underlying private Sequence and private Blobs can be deleted.

6 Likes