func (m *multiReadCloser) Close() error { c := new(utils.CompositeError) for ; m.index < len(m.readers); m.index++ { err := m.readers[m.index].Close() if err != nil { c.AppendError(err) } } if c.Empty() { c = nil } return c }
//!TODO this shoulde be redone when a more certain naming is imposed on files and directories func (d *Disk) loadFromDisk() error { if meta, err := d.readMetaFromDisk(); err != nil || meta.PartSize != d.partSize { e := new(utils.CompositeError) e.AppendError(err) d.logger.Logf("%s is going to be removed.", d.path) e.AppendError(os.RemoveAll(d.path)) return e } d.logger.Logf("%s is going to be loaded for reusage by storage.disk", d.path) root, err := os.Open(d.path) if err != nil { e := new(utils.CompositeError) e.AppendError(err) d.logger.Logf("%s is going to be removed.", d.path) e.AppendError(os.RemoveAll(d.path)) return err } infos, err := root.Readdir(-1) if err != nil { d.logger.Logf("Got error while reading the files in the storage root - %s", err) } for _, info := range infos { if info.IsDir() { // cache_key file, err := os.Open(filepath.Join(d.path, info.Name())) if err != nil { d.logger.Logf("Got error while loading cache for key %s:\n%s", info.Name(), err) continue } walker := newDiskWalker(d, file) walker.Walk() } } return nil }