<commit_before>// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package filestorage

import (
	"io"
	"time"
)

// FileStorage is an abstraction of a system that can be used for the
// storage of files.  The type exposes the essential capabilities of
// such a system.
type FileStorage interface {
	Metadata(id string) (Metadata, error)
	Get(id string) (Metadata, io.ReadCloser, error)
	List() ([]Metadata, error)
	Add(meta Metadata, archive io.Reader) (string, error)
	SetFile(id string, file io.Reader) error
	Remove(id string) error
}

type Metadata interface {
	// ID is the unique ID assigned by the storage system.
	ID() string
	// Size is the size of the file (in bytes).
	Size() int64
	// Checksum is the checksum for the file.
	Checksum() string
	// ChecksumFormat is the kind (and encoding) of checksum.
	ChecksumFormat() string
	// Timestamp records when the file was created.
	Timestamp() time.Time
	// Stored indicates whether or not the file has been stored.
	Stored() bool

	// Doc returns a storable copy of the metadata.
	Doc() interface{}
	// SetID sets the ID of the metadata.  If the ID is already set,
	// SetID() should return true (false otherwise).
	SetID(id string) (alreadySet bool)
	// SetFile sets the file info on the metadata.
	SetFile(size int64, checksum, checksumFormat string) error
	// SetStored sets Stored to true on the metadata.
	SetStored()
}

// DocStorage is an abstraction for a system that can store docs (structs).
// The system is expected to generate its own unique ID for each doc.<commit_msg>Add missing doc comments to the interfaces.<commit_after>// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package filestorage

import (
	"io"
	"time"
)

// FileStorage is an abstraction of a system that can be used for the
// storage of files.  The type exposes the essential capabilities of
// such a system.
type FileStorage interface {
	// Metadata returns a file's metadata.
	Metadata(id string) (Metadata, error)
	// Get returns a file and its metadata.
	Get(id string) (Metadata, io.ReadCloser, error)
	// List returns the metadata for each stored file.
	List() ([]Metadata, error)
	// Add stores a file and its metadata.
	Add(meta Metadata, archive io.Reader) (string, error)
	// SetFile stores a file for an existing metadata entry.
	SetFile(id string, file io.Reader) error
	// Remove removes a file from storage.
	Remove(id string) error
}

// Metadata is the meta information for a stored file.
type Metadata interface {
	// ID is the unique ID assigned by the storage system.
	ID() string
	// Size is the size of the file (in bytes).
	Size() int64
	// Checksum is the checksum for the file.
	Checksum() string
	// ChecksumFormat is the kind (and encoding) of checksum.
	ChecksumFormat() string
	// Timestamp records when the file was created.
	Timestamp() time.Time
	// Stored indicates whether or not the file has been stored.
	Stored() bool

	// Doc returns a storable copy of the metadata.
	Doc() interface{}
	// SetID sets the ID of the metadata.  If the ID is already set,
	// SetID() should return true (false otherwise).
	SetID(id string) (alreadySet bool)
	// SetFile sets the file info on the metadata.
	SetFile(size int64, checksum, checksumFormat string) error
	// SetStored sets Stored to true on the metadata.
	SetStored()
}

// DocStorage is an abstraction for a system that can store docs (structs).
// The system is expected to generate its own unique ID for each doc.
{'fraction_non_alphanumeric': 0.08423142370958593, 'fraction_numerical': 0.005104934770277935, 'mean_word_length': 3.5984354628422426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3796044', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1021, 'n_words': 498}