file_snapshot.go
func (s *FileSnapshotSink) finalize() error {
	// Flush any remaining data
	if err := s.buffered.Flush(); err != nil {
		return err
	}

	// Sync to force fsync to disk
	if err := s.stateFile.Sync(); err != nil {
		return err
	}

	// Get the file size
	stat, statErr := s.stateFile.Stat()

	// Close the file
	if err := s.stateFile.Close(); err != nil {
		return err
	}

	// Set the file size, check after we close
	if statErr != nil {
		return statErr
	}
	s.meta.Size = stat.Size()

	// Set the CRC
	s.meta.CRC = s.stateHash.Sum(nil)
	return nil
}
func (s *FileSnapshotSink) finalize() error {
	// Flush any remaining data
	if err := s.buffered.Flush(); err != nil {
		return err
	}

	// Sync to force fsync to disk
	if err := s.stateFile.Sync(); err != nil {
		return err
	}

	// Get the file size
	stat, statErr := s.stateFile.Stat()

	// Close the file
	if err := s.stateFile.Close(); err != nil {
		return err
	}

	// Set the file size, check after we close
	if statErr != nil {
		return statErr
	}
	s.meta.Size = stat.Size()

	// Set the CRC
	s.meta.CRC = s.stateHash.Sum(nil)
	return nil
}
func ( s * FileSnapshotSink ) finalize ( ) error { // Flush any remaining data if err := s . buffered . Flush ( ) ; err != nil { return err } // Sync to force fsync to disk if err := s . stateFile . Sync ( ) ; err != nil { return err } // Get the file size stat , statErr := s . stateFile . Stat ( ) // Close the file if err := s . stateFile . Close ( ) ; err != nil { return err } // Set the file size, check after we close if statErr != nil { return statErr } s . meta . Size = stat . Size ( ) // Set the CRC s . meta . CRC = s . stateHash . Sum ( nil ) return nil }
// finalize is used to close all of our resources.
finalize is used to close all of our resources .