Clean up access a bit
parent
a26782d6cd
commit
bb541a8193
@ -1,30 +1,33 @@
|
||||
package domain
|
||||
|
||||
import "io"
|
||||
//import "io"
|
||||
|
||||
type BogFileService struct {
|
||||
user_agent_repo UserAgentRepository
|
||||
file_data_repo FileDataRepository
|
||||
}
|
||||
|
||||
func (b *BogFileService) RecieveFile(src FileSource) error {
|
||||
f, err := b.file_data_repo.OpenOrCreate(src.Path(), src.UserAgent())
|
||||
func (b BogFileService) CreateOrOpenInFile(ref FileReference) (BogInFile ,error) {
|
||||
user_agent, err := b.user_agent_repo.GetByName(ref.UserAgent)
|
||||
|
||||
|
||||
f, err := b.file_data_repo.Create(ref.Path, string(user_agent.ID))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
io.Copy(f, src)
|
||||
return nil
|
||||
return f, err
|
||||
}
|
||||
|
||||
func (b *BogFileService) SendFile(dst FileDestination) error {
|
||||
f, err := b.file_data_repo.OpenOrCreate(dst.Path(), dst.UserAgent())
|
||||
func (b BogFileService) OpenOutFile(ref FileReference) (BogOutFile, error) {
|
||||
user_agent, err := b.user_agent_repo.GetByName(ref.UserAgent)
|
||||
|
||||
f, err := b.file_data_repo.Open(ref.Path, string(user_agent.ID))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
io.Copy(dst, f)
|
||||
return nil
|
||||
return f, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue