Compare commits
No commits in common. "01970b2bb7701a5e78e35348247eb4292cc12b0d" and "3e9957d419616768438692ae476c72a8be8a1649" have entirely different histories.
01970b2bb7
...
3e9957d419
15
blefs/all.go
15
blefs/all.go
@ -38,19 +38,12 @@ func (blefs *FS) removeAllChildren(path string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range list {
|
for _, entry := range list {
|
||||||
name := entry.Name()
|
|
||||||
|
|
||||||
if name == "." || name == ".." {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
entryPath := filepath.Join(path, name)
|
|
||||||
|
|
||||||
if entry.IsDir() {
|
if entry.IsDir() {
|
||||||
err = blefs.removeAllChildren(entryPath)
|
err = blefs.removeAllChildren(filepath.Join(path, entry.Name()))
|
||||||
} else {
|
} else {
|
||||||
err = blefs.Remove(entryPath)
|
err = blefs.Remove(path)
|
||||||
}
|
}
|
||||||
if err != nil && err.(FSError).Code != -2 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +58,7 @@ func (blefs *FS) MkdirAll(path string) error {
|
|||||||
|
|
||||||
splitPath := strings.Split(path, "/")
|
splitPath := strings.Split(path, "/")
|
||||||
for i := 1; i < len(splitPath); i++ {
|
for i := 1; i < len(splitPath); i++ {
|
||||||
curPath := strings.Join(splitPath[0:i+1], "/")
|
curPath := strings.Join(splitPath[0:i], "/")
|
||||||
|
|
||||||
err := blefs.Mkdir(curPath)
|
err := blefs.Mkdir(curPath)
|
||||||
if err != nil && err.(FSError).Code != -17 {
|
if err != nil && err.(FSError).Code != -17 {
|
||||||
|
21
resources.go
21
resources.go
@ -77,16 +77,12 @@ func LoadResources(file *os.File, fs *blefs.FS) (<-chan ResourceLoadProgress, er
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Msg("Decoded manifest file")
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(out)
|
defer close(out)
|
||||||
|
|
||||||
for _, file := range manifest.Obsolete {
|
for _, file := range manifest.Obsolete {
|
||||||
name := filepath.Base(file.Path)
|
name := filepath.Base(file.Path)
|
||||||
|
|
||||||
log.Debug().Str("file", file.Path).Msg("Removing file")
|
|
||||||
|
|
||||||
err := fs.RemoveAll(file.Path)
|
err := fs.RemoveAll(file.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out <- ResourceLoadProgress{
|
out <- ResourceLoadProgress{
|
||||||
@ -97,8 +93,6 @@ func LoadResources(file *os.File, fs *blefs.FS) (<-chan ResourceLoadProgress, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Str("file", file.Path).Msg("Removed file")
|
|
||||||
|
|
||||||
out <- ResourceLoadProgress{
|
out <- ResourceLoadProgress{
|
||||||
Name: name,
|
Name: name,
|
||||||
Operation: ResourceOperationRemoveObsolete,
|
Operation: ResourceOperationRemoveObsolete,
|
||||||
@ -127,11 +121,8 @@ func LoadResources(file *os.File, fs *blefs.FS) (<-chan ResourceLoadProgress, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Str("file", file.Path).Msg("Making directories")
|
|
||||||
|
|
||||||
err = fs.MkdirAll(filepath.Dir(file.Path))
|
err = fs.MkdirAll(filepath.Dir(file.Path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug().Err(err).Msg("Error making directories")
|
|
||||||
out <- ResourceLoadProgress{
|
out <- ResourceLoadProgress{
|
||||||
Name: file.Name,
|
Name: file.Name,
|
||||||
Operation: ResourceOperationUpload,
|
Operation: ResourceOperationUpload,
|
||||||
@ -141,14 +132,8 @@ func LoadResources(file *os.File, fs *blefs.FS) (<-chan ResourceLoadProgress, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("file", file.Path).
|
|
||||||
Int64("size", srcFi.Size()).
|
|
||||||
Msg("Creating file")
|
|
||||||
|
|
||||||
dst, err := fs.Create(file.Path, uint32(srcFi.Size()))
|
dst, err := fs.Create(file.Path, uint32(srcFi.Size()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug().Err(err).Msg("Error creating file")
|
|
||||||
out <- ResourceLoadProgress{
|
out <- ResourceLoadProgress{
|
||||||
Name: file.Name,
|
Name: file.Name,
|
||||||
Operation: ResourceOperationUpload,
|
Operation: ResourceOperationUpload,
|
||||||
@ -161,11 +146,6 @@ func LoadResources(file *os.File, fs *blefs.FS) (<-chan ResourceLoadProgress, er
|
|||||||
progCh := dst.Progress()
|
progCh := dst.Progress()
|
||||||
go func() {
|
go func() {
|
||||||
for sent := range progCh {
|
for sent := range progCh {
|
||||||
log.Debug().
|
|
||||||
Int64("total", srcFi.Size()).
|
|
||||||
Uint32("sent", sent).
|
|
||||||
Msg("Progress event sent")
|
|
||||||
|
|
||||||
out <- ResourceLoadProgress{
|
out <- ResourceLoadProgress{
|
||||||
Name: file.Name,
|
Name: file.Name,
|
||||||
Operation: ResourceOperationUpload,
|
Operation: ResourceOperationUpload,
|
||||||
@ -181,7 +161,6 @@ func LoadResources(file *os.File, fs *blefs.FS) (<-chan ResourceLoadProgress, er
|
|||||||
|
|
||||||
n, err := io.Copy(dst, src)
|
n, err := io.Copy(dst, src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug().Err(err).Msg("Error writing to file")
|
|
||||||
out <- ResourceLoadProgress{
|
out <- ResourceLoadProgress{
|
||||||
Name: file.Name,
|
Name: file.Name,
|
||||||
Operation: ResourceOperationUpload,
|
Operation: ResourceOperationUpload,
|
||||||
|
Reference in New Issue
Block a user