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