Ejemplo n.º 1
0
// Purge deletes all the files and directories
//
// Implemented here so we can make sure we delete directory markers
func (f *Fs) Purge() error {
	// Delete all the files including the directory markers
	toBeDeleted := make(chan fs.Object, fs.Config.Transfers)
	delErr := make(chan error, 1)
	go func() {
		delErr <- fs.DeleteFiles(toBeDeleted)
	}()
	err := f.list("", fs.MaxLevel, func(remote string, object *swift.Object, isDirectory bool) error {
		if !isDirectory {
			o, err := f.newObjectWithInfo(remote, object)
			if err != nil {
				return err
			}
			toBeDeleted <- o
		}
		return nil
	})
	close(toBeDeleted)
	delError := <-delErr
	if err == nil {
		err = delError
	}
	if err != nil {
		return err
	}
	return f.Rmdir()
}
Ejemplo n.º 2
0
// Purge deletes all the files and directories
//
// Implemented here so we can make sure we delete directory markers
func (f *Fs) Purge() error {
	// Delete all the files including the directory markers
	toBeDeleted := make(chan fs.Object, fs.Config.Transfers)
	var err error
	go func() {
		err = f.list("", fs.MaxLevel, func(remote string, object *swift.Object, isDirectory bool) error {
			if !isDirectory {
				if o := f.newFsObjectWithInfo(remote, object); o != nil {
					toBeDeleted <- o
				}
			}
			return nil
		})
		close(toBeDeleted)
	}()
	fs.DeleteFiles(toBeDeleted)
	if err != nil {
		return err
	}
	return f.Rmdir()
}
Ejemplo n.º 3
0
// NewRun initialise the remote and local for testing and returns a
// run object.  Call this from the tests.
//
// r.flocal is an empty local Fs
// r.fremote is an empty remote Fs
//
// Finalise() will tidy them away when done.
func NewRun(t *testing.T) *Run {
	var r *Run
	if *Individual {
		r = newRun()
	} else {
		// If not individual, use the global one with the clean method overridden
		r = new(Run)
		*r = *oneRun
		r.cleanRemote = func() {
			oldErrors := fs.Stats.GetErrors()
			fs.DeleteFiles(r.fremote.List())
			errors := fs.Stats.GetErrors() - oldErrors
			if errors != 0 {
				t.Fatalf("%d errors while cleaning remote %v", errors, r.fremote)
			}
		}
	}
	r.Logf = t.Logf
	r.Fatalf = t.Fatalf
	r.Logf("Remote %q, Local %q, Modify Window %q", r.fremote, r.flocal, fs.Config.ModifyWindow)
	return r
}
Ejemplo n.º 4
0
// Purge deletes all the files and directories
//
// Implemented here so we can make sure we delete directory markers
func (f *Fs) Purge() error {
	fs.DeleteFiles(f.listFiles(true))
	return f.Rmdir()
}