## KernelDB.register_file()


Register a single kernel file and return its SHA-256.


Usage

``` python
KernelDB.register_file(
    path, mission=None, source_url=None, archive_dir=None, expected_hash=None
)
```


If the file's content is already in the database under a different filename, the new location is still recorded and points to the same hash. That is what happens when JUICE ships `jup365_19900101_20500101.bsp` and generic_kernels has `jup365.bsp`: same content, different names, one hash. The match is logged at the `INFO` level.

If the path was registered before under another hash, that location is stale. It is deleted, and the old kernel row is marked superseded by the new hash. This applies to every stale row at the path, not only one.


## Parameters


`path: str | Path`  
The kernel file.

`mission: str | None = None`  
The mission to file it under, canonicalised. `None` guesses it with `guess_mission` and the database's kernel roots.

`source_url: str | None = None`  
Where the file was downloaded from, stored with the location.

`archive_dir: str | Path | None = None`  
If given, the file is moved to `<archive_dir>/<mission>/<kernel_type>/<filename>` and a symlink is left at the original location.

`expected_hash: str | None = None`  
If given, the computed SHA-256 is compared with it before anything is stored (Issue 7).


## Returns


`str`  
The file's SHA-256 hex digest.


## Raises


`FileNotFoundError`  
*path* is not a file.

`ValueError`  
The computed hash differs from *expected_hash*.
