Backend shutdowner interface

I'm looking for a way to run some code at the end of the backend's lifecycle. I've read the discussion at The end of use of a backend . Was going to use lib/atexit , but stumbled upon the Shutdowner interface, which seems to be a much cleaner way to solve my task. Unfortunately, my backend's Shutdown() function do not being called. Related code:

func (f *Fs) Shutdown(ctx context.Context) error {
	panic("SHUTDOWN")
}

var (
	_ fs.Fs         = (*Fs)(nil)
	_ fs.Shutdowner = (*Fs)(nil)
)

Any suggestions?

I don't actually think the Shutdown method is being called at the moment.

The intention was it would be called when a backend dropped out of the backend cache, or possibly on program exit.

What do you need it for in your backend?

I'm working on the backend, which allows storing files directly in Tar archives. I need to write an archive footer (2x zero blocks) after the sync or copy session ends.

PS:
Also, I've noticed some other methods in my backend are not being called at all:

  • (f *Fs) Mkdir
  • (f *Fs) Rmdir
  • (f *Fs) NewObject

Are they reserved for future use too?

I wrote a similar backend (unreleased) which writes into zip files. For that I used libatexit.

The backend life-cycle isn't fixed yet.

What it would be nice to happen is that the Shutdown method gets called whenever a backend is no longer used, so at the end of the program or when a backend is removed from the backend cache...

I made an issue about this

Those should be called definitely depending on exactly what you are doing.