Documentation ¶
Index ¶
- Constants
- Variables
- func Restart()
- func Update(url string) bool
- type Project
- type ProjectDB
- func (p *ProjectDB) Add(proj Project) error
- func (p *ProjectDB) Exists(projectName string) bool
- func (p *ProjectDB) Find(projectName string) (*Project, bool)
- func (p *ProjectDB) Projects() []*Project
- func (p *ProjectDB) Reload() error
- func (p *ProjectDB) Remove(projectName string) error
- func (p *ProjectDB) Update(f func() *Project) error
- type ProjectFileChange
- type ProjectFileEntry
- type ProjectFileInfo
- type ProjectFileLocation
- type ProjectFileStatus
- type TrackingOptions
Constants ¶
const UnsetOption = 0
UnsetOption unsets the option.
Variables ¶
var ( // ErrBadProjectFileStatusString status string is unknown. ErrBadProjectFileStatusString = fmt.Errorf("unknown string value for ProjectFileStatus") // ErrBadProjectFileLocationString file location is unknown ErrBadProjectFileLocationString = fmt.Errorf("unknown string value for ProjectFileLocation") )
Functions ¶
func Restart ¶
func Restart()
Restart restarts the materials command. It starts a new command and then exits the current command. The new command is started using nohup so the parent exiting doesn't terminate it. The new command also does a retry on the port to give the parent some time to exit and release it.
func Update ¶
Update replaces the current binary with a new one if they are different. It determines if they are different by comparing their checksum's. Update downloads the binary at the specified url. It modifies the url to include the os type in the path. This is determined by using runtime.GOOS.
Types ¶
type Project ¶
type Project struct { Name string Path string Status string ModTime time.Time MCId string Changes map[string]ProjectFileChange Ignore []string *leveldb.DB `json:"-"` }
Project describes the information we track about a users projects. Here we keep the name of the project and the directory path. The name of the project is the top level directory of the project. The path is the full path to the project including the name (top level directory).
func NewProject ¶
NewProject creates a new project instance.
func (*Project) AddFileChange ¶
func (p *Project) AddFileChange(fileChange ProjectFileChange)
AddFileChange adds a file change event to the project.
func (*Project) RemoveFileChange ¶
RemoveFileChange removes the change for a file path.
func (Project) Tree ¶
func (p Project) Tree() ([]*ProjectFileEntry, error)
Tree builds the tree for a project that can be used to traverse and display the files and directories in a project.
func (*Project) Walk ¶
func (project *Project) Walk(options *TrackingOptions) error
Walk walks a project and determines status.
type ProjectDB ¶
type ProjectDB struct {
// contains filtered or unexported fields
}
ProjectDB contains a list of user projects and information that is needed by the methods to load the projects file.
func CurrentUserProjectDB ¶
func CurrentUserProjectDB() *ProjectDB
CurrentUserProjectDB opens the project database for a user contained in $HOME/.materials/projectdb. Only opens the database once per process, regardless of how many times it is called.
func OpenProjectDB ¶
OpenProjectDB loads projects from the database directory at path. Project files are JSON files ending with a .project extension.
func (*ProjectDB) Find ¶
Find returns (Project, true) if the project is found otherwise it returns (Project{}, false).
type ProjectFileChange ¶
ProjectFileChange contains information about the change that occurred to a file in a project.
type ProjectFileEntry ¶
type ProjectFileEntry struct { ID string `json:"id"` ParentID string `json:"parent_id"` Level int `json:"level"` Path string `json:"path"` HrefPath string `json:"hrefpath"` DisplayName string `json:"displayname"` Type string `json:"type"` Children []*ProjectFileEntry `json:"children"` }
ProjectFileEntry is a file entry in a project.
type ProjectFileInfo ¶
type ProjectFileInfo struct { Path string Size int64 Hash string ModTime time.Time ID string Status ProjectFileStatus Location ProjectFileLocation }
ProjectFileInfo holds all the information on a project file.
type ProjectFileLocation ¶
type ProjectFileLocation int
ProjectFileLocation is the location of a file.
const ( // LocalOnly the file exists only on the local client LocalOnly ProjectFileLocation = iota // RemoteOnly the file exists only on the server RemoteOnly // LocalAndRemote the file exists both on the local client and the server LocalAndRemote // LocalAndRemoteUnknown the exact location of the file cannot be determined LocalAndRemoteUnknown )
func String2ProjectFileLocation ¶
func String2ProjectFileLocation(pfl string) (p ProjectFileLocation, err error)
String2ProjectFileLocation converts a string to ProjectFileLocation
func (ProjectFileLocation) String ¶
func (pfl ProjectFileLocation) String() string
String implements the Stringer interface for ProjectFileLocation.
type ProjectFileStatus ¶
type ProjectFileStatus int
ProjectFileStatus is the state of a file in the project.
const ( // Synchronized the file has been synchronized with the server Synchronized ProjectFileStatus = iota // Unsynchronized the file hasn't been synched with the server Unsynchronized // New the file is new on the client New // Deleted the file has been deleted Deleted // UnknownFileStatus we can't determine the files status UnknownFileStatus )
func String2ProjectFileStatus ¶
func String2ProjectFileStatus(pfs string) (ProjectFileStatus, error)
String2ProjectFileStatus converts a string to a ProjectFileStatus
func (ProjectFileStatus) String ¶
func (pfs ProjectFileStatus) String() string
String implements the string interface for ProjectFileStatus
type TrackingOptions ¶
type TrackingOptions struct { FileStatus ProjectFileStatus FileLocation ProjectFileLocation }
TrackingOptions describes a files status and location.