func (repo *RepositoryConfig) segmentToMediaKind(segment string) MediaKind {
	kind, ok := map[string]MediaKind{
		"collected": MediaCollected,
		"motion":    MediaMotion,
		"pinned":    MediaSaved,
		"generated": MediaGenerated,
	}[segment]
	if !ok {
		return MediaUnknown
	}
	return kind
}
/*
 * Directory Structure
 *
 * The base media directory for a given camera is
 * {{.BaseDirectory}}/{{.CameraID}}/{{.MediaData}} -- that is, all images
 * received from that camera are stored in this tree.
 *
 * Images are content-addressed, via their SHA2-256 hashes. However to help
 * avoid filesystem directory-entry limits, they are grouped in intermediate
 * directories based on the first 3 characters of their hash.
 *
 * So for example, a file received from `dachacam` might be stored as:
 * /path/to/images/dachacam/data/fee/feedfacedeadbeefcafebabef00db0a71337b00bc001b0a7.jpg
 *
 * Once so stored, these images must be pinned or they'll be reclaimed by the
 * next GC run. An image may be pinned in one or more other media kinds.
 * Pinning is a symlink from a kind directory to the data directory, but with
 * no intermediate grouping directory.
 *
 * For instance the data file above could be marked as pinned as a
 * MediaCollected via this creation of this file pointing to it as a symlink:
 * /path/to/images/dachacam/collected/feedfacedeadbeefcafebabef00db0a71337b00bc001b0a7.jpg
 *
 * Collected images are purged every 24 hours, via the removal of the symlink.
 *
 * Motion images are pushed in response to camera-side motion detection. They
 * are purged every 24 hours.
 *
 * Generated media -- basically timelapses -- are constructed daily per some
 * schedule. Only photos from collected and motion sets are eligible to be used
 * to generate images. Generated images are purged after 14 days.
 *
 * Saved images are images flagged by the user for permanent retention. They
 * are, obviously, never purged.
 *
 * As above, any base data file not pinned via one of the other types is purged
 * on the next GC run.
 */
Directory Structure

The base media directory for a given camera is
{{.BaseDirectory}}/{{.CameraID}}/{{.MediaData}} -- that is, all images
received from that camera are stored in this tree.

Images are content-addressed, via their SHA2-256 hashes. However to help
avoid filesystem directory-entry limits, they are grouped in intermediate
directories based on the first 3 characters of their hash.



Once so stored, these images must be pinned or they'll be reclaimed by the
next GC run. An image may be pinned in one or more other media kinds.
Pinning is a symlink from a kind directory to the data directory, but with
no intermediate grouping directory.



Collected images are purged every 24 hours, via the removal of the symlink.

Motion images are pushed in response to camera-side motion detection. They
are purged every 24 hours.

Generated media -- basically timelapses -- are constructed daily per some
schedule. Only photos from collected and motion sets are eligible to be used
to generate images. Generated images are purged after 14 days.

Saved images are images flagged by the user for permanent retention. They
are, obviously, never purged.

As above, any base data file not pinned via one of the other types is purged
on the next GC run.
/ * * Directory Structure * * The base media directory for a given camera is * {{ . BaseDirectory }} / {{ . CameraID }} / {{ . MediaData }} -- that is all images * received from that camera are stored in this tree . * * Images are content - addressed via their SHA2 - 256 hashes . However to help * avoid filesystem directory - entry limits they are grouped in intermediate * directories based on the first 3 characters of their hash . * * So for example a file received from ` dachacam ` might be stored as : * / path / to / images / dachacam / data / fee / feedfacedeadbeefcafebabef00db0a71337b00bc001b0a7 . jpg * * Once so stored these images must be pinned or they ' ll be reclaimed by the * next GC run . An image may be pinned in one or more other media kinds . * Pinning is a symlink from a kind directory to the data directory but with * no intermediate grouping directory . * * For instance the data file above could be marked as pinned as a * MediaCollected via this creation of this file pointing to it as a symlink : * / path / to / images / dachacam / collected / feedfacedeadbeefcafebabef00db0a71337b00bc001b0a7 . jpg * * Collected images are purged every 24 hours via the removal of the symlink . * * Motion images are pushed in response to camera - side motion detection . They * are purged every 24 hours . * * Generated media -- basically timelapses -- are constructed daily per some * schedule . Only photos from collected and motion sets are eligible to be used * to generate images . Generated images are purged after 14 days . * * Saved images are images flagged by the user for permanent retention . They * are obviously never purged . * * As above any base data file not pinned via one of the other types is purged * on the next GC run . * /
func (repo *RepositoryConfig) segmentToMediaKind(segment string) MediaKind {
	kind, ok := map[string]MediaKind{
		"collected": MediaCollected,
		"motion":    MediaMotion,
		"pinned":    MediaSaved,
		"generated": MediaGenerated,
	}[segment]
	if !ok {
		return MediaUnknown
	}
	return kind
}
func ( repo * RepositoryConfig ) segmentToMediaKind ( segment string ) MediaKind { kind , ok := map [ string ] MediaKind { " " : MediaCollected , " " : MediaMotion , " " : MediaSaved , " " : MediaGenerated , } [ segment ] if ! ok { return MediaUnknown } return kind }
Directory Structure
Directory Structure