Versions.. FilesContainers cf NRS

So, I’m trying to understand versions and rather doing that back to front by looking at what I see.

As an example safe://cdn

From dog I see there have been 6 versions of what I wonder is the FilesContainer
and with cat (though this should be ls), I can scroll through versions of what I understand is the FilesContainer
eg safe cat safe://hnyynyzeu1mxk4pa61a6skyp31yzh3doq1pqcdd8n5f33hepbyaqao54u6bnc?v=4

Now, the dog barks currently as v=1:

$ safe dog safe://cdn?v=1
Native data type: PublishedSeqAppendOnlyData
Version: 6
Type tag: 1100
XOR name: 0xd1392dead371e963d6501b9902fcc8e0e935cc18ce2d9739e21a1061d886f53f
XOR-URL: safe://hnyynyzeu1mxk4pa61a6skyp31yzh3doq1pqcdd8n5f33hepbyaqao54u6bnc?v=6

Resolved using NRS Map:
PublicName: "cdn"
Container XOR-URL: safe://hnyydyz7h69nmeb6ttbz4gw3k8tpmhou4aoxpq9okah7hnemz4gha8r86qbqh?v=1
Native data type: PublishedSeqAppendOnlyData
Type tag: 1500
XOR name: 0xfbcf7c4b407d1886fa3532a3c5abe427ac41ed77e0ac73bc12177d1b98390fe7
Version: 1
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+
| NRS name/subname | Created              | Modified             | Link                                                                     |
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+
| cdn              | 2020-04-11T18:38:53Z | 2020-04-11T18:38:53Z | safe://hnyynyzeu1mxk4pa61a6skyp31yzh3doq1pqcdd8n5f33hepbyaqao54u6bnc?v=6 |
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+

Previously as v=0

safe@water:~$ safe dog safe://cdn?v=0
Native data type: PublishedSeqAppendOnlyData
Version: 0
Type tag: 1100
XOR name: 0xd1392dead371e963d6501b9902fcc8e0e935cc18ce2d9739e21a1061d886f53f
XOR-URL: safe://hnyynyzeu1mxk4pa61a6skyp31yzh3doq1pqcdd8n5f33hepbyaqao54u6bnc?v=0

Resolved using NRS Map:
PublicName: "cdn"
Container XOR-URL: safe://hnyydyz7h69nmeb6ttbz4gw3k8tpmhou4aoxpq9okah7hnemz4gha8r86qbqh?v=0
Native data type: PublishedSeqAppendOnlyData
Type tag: 1500
XOR name: 0xfbcf7c4b407d1886fa3532a3c5abe427ac41ed77e0ac73bc12177d1b98390fe7
Version: 0
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+
| NRS name/subname | Created              | Modified             | Link                                                                     |
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+
| cdn              | 2020-04-09T12:58:06Z | 2020-04-09T12:58:06Z | safe://hnyynyzeu1mxk4pa61a6skyp31yzh3doq1pqcdd8n5f33hepbyaqao54u6bnc?v=0 |
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+

Does this suggest that a domain name β€œnrs” (why do we call it acronym nrs?)
is only updated when the owner prompts that… and up to that point updates are to FileContainer… which I guess makes sense, if you are prepping the future instance of an entire site, you then choose to switch it as live/latest version of nrs.

Two questions then:
1of2: am I correct expecting that sync will update only the FilesContainer?
2of2 what is the command that updates nrs version?.. I worry that nrs add will create subdomain but does it perhaps overwrite and iterate the version for the nrs?

(yes, I should rtfm :))

3 Likes

Confession: I made a mess of safe://cdn and managed to upload a copy of the entire dir as a subdir. It looks sorted now. See if you get the same results as me, please.

local copy
willie@gagarin:~/projects/maidsafe/local_sites$ tree cdn
cdn
β”œβ”€β”€ css
β”‚ β”œβ”€β”€ southside.css
β”‚ └── style.css
β”œβ”€β”€ js
β”‚ └── vue.min.js
└── media
β”œβ”€β”€ images
β”‚ β”œβ”€β”€ vm-Socks-blue.png
β”‚ └── vm-Socks-green.png
└── sounds

shared-section copy:
illie@gagarin:~/projects/maidsafe/local_sites$ safe files tree safe://cdn
safe://cdn
β”œβ”€β”€ css
β”‚ β”œβ”€β”€ southside.css
β”‚ └── style.css
β”œβ”€β”€ js
β”‚ └── vue.min.js
└── media
└── images
β”œβ”€β”€ vm-Socks-blue.png
└── vm-Socks-green.png

The command I used was:
willie@gagarin:~/projects/maidsafe/local_sites$ safe files sync cdn/ safe://cdn --recursive --delete --update-nrs
FilesContainer synced up (version 8): β€œsafe://cdn”

  • cdn/media/images/vm-Socks-blue.png safe://hbwynynpejco5uu8fd5ktxirjcjtg91mfbr1umpexje3rphktm6bcfrth7

EDIT: As expected, note the empty β€œsounds” sub-dir in my local copy is not shown in the copy on the shared section.

1 Like

So, from what I read previously as [v6 FilesContainer and v1 nrs]
on the back of apparently only safe files sync
now [v7 FilesContainer and v2 nrs]

$ safe dog safe://cdn
Native data type: PublishedSeqAppendOnlyData
Version: 8
Type tag: 1100
XOR name: 0xd1392dead371e963d6501b9902fcc8e0e935cc18ce2d9739e21a1061d886f53f
XOR-URL: safe://hnyynyzeu1mxk4pa61a6skyp31yzh3doq1pqcdd8n5f33hepbyaqao54u6bnc?v=8

Resolved using NRS Map:
PublicName: "cdn"
Container XOR-URL: safe://hnyydyz7h69nmeb6ttbz4gw3k8tpmhou4aoxpq9okah7hnemz4gha8r86qbqh
Native data type: PublishedSeqAppendOnlyData
Type tag: 1500
XOR name: 0xfbcf7c4b407d1886fa3532a3c5abe427ac41ed77e0ac73bc12177d1b98390fe7
Version: 2
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+
| NRS name/subname | Created              | Modified             | Link                                                                     |
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+
| cdn              | 2020-04-12T19:11:57Z | 2020-04-12T19:11:57Z | safe://hnyynyzeu1mxk4pa61a6skyp31yzh3doq1pqcdd8n5f33hepbyaqao54u6bnc?v=8 |
+------------------+----------------------+----------------------+--------------------------------------------------------------------------+

What prompts an update to FilesContainer and NOT nrs?.. is that just individual files put perhaps??

2 Likes

I think so. @bochaco or @joshuef will be able to give a definitive answer

Not quite: safe files sync command updates a FilesContainer if there have been any modifications in the set of source files (new, modified or deleted files). In addition, it will also update the NRS pointing to the FileContainer if:

  • the target parameter is the NRS URL instead of the FileContainer XOR URL.
  • the --update-nrs flag is passed to the command

safe nrs add does update the version. It has 2 exclusive modes:

  • either it updates the link of an existing name
  • or it adds a subname to an existing name (or updates its link if the subname already exists)

In the first case the name to pass is the complete existing name, in the second case the name to pass ends with an existing name (in the format subname.name). So, there can be no confusion between the 2 modes. If you worry to create a subdomain by accident, just never use a dot in the name argument.

EDIT: Also never use a slash in a NRS name or subname to avoid the confusion you came across a few days ago. Because something like safe://hello/style.hello is ambiguous:

  • it can mean style.hello file in container pointed to by safe://hello NRS map
  • it can mean hello/style subname of safe://hello NRS map

I think the NRS API should generate an error when a user creates a name or adds a subname with slashes in them.

6 Likes

Good shout. I’ve made https://github.com/maidsafe/safe-api/issues/517 to track that.


Basically it is never assumed you want to update the NRS unless you opt in. Any files command changes to an existing FilesContainer will apply to that container only. Your NRS map points to a specific version of the FilesContainer so will never be affected unless you opt in to updating it with the command flag.

6 Likes

Sharing this again, to see if we get some type of consensus about this change or not:

There are suggestions to make an NRS update the default with perhaps an optional --no-nrs-update flag: https://github.com/maidsafe/safe-api/issues/492

2 Likes

How common would the use case be when you don’t want to update the NRS-URL? Unless it’s very common I’d suggest treating both the NRS and XOR cases the same to avoid confusion, with the --no-nrs-update flag added as an option.

In my playing around I have hit this issue a couple of times, when I expected the NRS URL to point to the new version and it didn’t.

3 Likes

If user bothers to pass NRS map URL instead of direct FilesContainer URL, most probably he wants to update NRS map as well.

So, in summary there are 3 cases in safe files sync command:

  • FilesContainer URL is passed => there is no NRS map to update
  • NRS map URL is passed without --no-nrs-update option => update NRS map
  • NRS map URL is passed with --no-nrs-update option => don’t update NRS map

I think the latter case will be used very rarely.

3 Likes

Just as a comment, note there is no other choice for this, we cannot figure out if a FilesContainer is linked from an NRS when the user provides a FilesContainer XOR-URL

4 Likes

Yes of course. I have edited to: there is no NRS map to update

1 Like