Skip to content

Wings only cleans up failed transfer if it also fails to set transfer status on panel #5555

@MrSoulPenguin

Description

@MrSoulPenguin

Current Behavior

The destination wings instance will only cleanup failed transferred files if the transfer isn't successful and it fails to update the panel about the transfer status.

if err := manager.Client().SetTransferStatus(context.Background(), trnsfr.Server.ID(), successful); err != nil {
	// Only delete the files if the transfer actually failed, otherwise we could have
	// unrecoverable data-loss.
	if !successful && err != nil {
		// Delete all extracted files.
		go func(trnsfr *transfer.Transfer) {
			_ = trnsfr.Server.Filesystem().UnixFS().Close()
			if err := os.RemoveAll(trnsfr.Server.Filesystem().Path()); err != nil && !os.IsNotExist(err) {
				trnsfr.Log().WithError(err).Warn("failed to delete local server files")
			}
		}(trnsfr)
	}

	trnsfr.Log().WithField("status", successful).WithError(err).Error("failed to set transfer status on panel")
	return
}

Expected Behavior

Wings should cleanup any leftover files of a failed transfer earlier in the deferral when the server is removed from the internal manager. So there aren't any left over files of a failed transfer.

Steps to Reproduce

Start a transfer between two nodes. Midway through the transfer, stop the source wings instance, inducing a transfer failure.

If the destination node was able to successfully set the transfer status on the panel, you should see the data directory for the transferred server left on the destination node.

If you make the panel inaccessible before stopping the source wings instance (like stopping nginx after the transfer starts), the destination wings instance will fail to update the panel and successfully cleanup the files as expected.

Panel Version

v1.12.0

Wings Version

v1.12.1

Games and/or Eggs Affected

No response

Docker Image

No response

Error Logs

Is there an existing issue for this?

  • I have searched the existing issues before opening this issue. I understand that maintainers may close this issue without communication if I have not provided sufficient information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions