github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/synchronization/paths.go (about) 1 package synchronization 2 3 import ( 4 "fmt" 5 "path/filepath" 6 7 "github.com/mutagen-io/mutagen/pkg/filesystem" 8 ) 9 10 // pathForSession computes the path to the serialized session for the given 11 // session identifier. An empty session identifier will return the sessions 12 // directory path. 13 func pathForSession(sessionIdentifier string) (string, error) { 14 // Compute/create the sessions directory. 15 sessionsDirectoryPath, err := filesystem.Mutagen(true, filesystem.MutagenSynchronizationSessionsDirectoryName) 16 if err != nil { 17 return "", fmt.Errorf("unable to compute/create sessions directory: %w", err) 18 } 19 20 // Success. 21 return filepath.Join(sessionsDirectoryPath, sessionIdentifier), nil 22 } 23 24 // pathForArchive computes the path to the serialized archive for the given 25 // session identifier. 26 func pathForArchive(session string) (string, error) { 27 // Compute/create the archives directory. 28 archivesDirectoryPath, err := filesystem.Mutagen(true, filesystem.MutagenSynchronizationArchivesDirectoryName) 29 if err != nil { 30 return "", fmt.Errorf("unable to compute/create archives directory: %w", err) 31 } 32 33 // Success. 34 return filepath.Join(archivesDirectoryPath, session), nil 35 }