Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7566 change the comments in the operations.DeleteFile as it does not use --backup-dir, despite comment #7621

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RONGALI-TARUN
Copy link

@RONGALI-TARUN RONGALI-TARUN commented Feb 8, 2024

What is the purpose of this change?

  1. leave operations.DeleteFile alone but fix the comment to say call DeleteFileWithBackupDir if --backup-dir support is required
  2. add a note to DeleteFileWithBackupDir noting that you use BackupDir to find the --backup-dir and that it is relatively expensive so don't put it in a loop

Was the change discussed in an issue or in the forum before?

yes
(#7566)

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@RONGALI-TARUN RONGALI-TARUN marked this pull request as ready for review February 8, 2024 06:31
@nielash
Copy link
Collaborator

nielash commented Feb 8, 2024

@RONGALI-TARUN thank you for working on this! This addresses 2 of the 3 items outlined on #7566. Are you interested in working on number 3 as well?

3. audit the existing call sides for operations.DeleteFile and try to figure out whether they should be obeying --backup-dir or not.

Also note that commit messages should be in this format.

@RONGALI-TARUN
Copy link
Author

@RONGALI-TARUN thank you for working on this! This addresses 2 of the 3 items outlined on #7566. Are you interested in working on number 3 as well?

  1. audit the existing call sides for operations.DeleteFile and try to figure out whether they should be obeying --backup-dir or not.

Also note that commit messages should be in this format.

hi @nielash
changed the msg format to the commit style
3. as i look through the code as far as i understand the function DeleteFileWithBackupDir is specifically created to address when we have provided the --backup-dir or else if we wanted to delete the file itself then we use the function DeleteFile.

@nielash
Copy link
Collaborator

nielash commented Feb 8, 2024

  1. as i look through the code as far as i understand the function DeleteFileWithBackupDir is specifically created to address when we have provided the --backup-dir or else if we wanted to delete the file itself then we use the function DeleteFile.

Right, to clarify -- the issue is that some functions that are currently calling operations.DeleteFile should really be calling operations.DeleteFileWithBackupDir instead. They may have assumed that they were using the backup-dir because of the incorrect comment on operations.DeleteFile, and now files are not getting backed up when they should be.

Here is an example:

deleteFileErr := operations.DeleteFile(s.ctx, src)

We actually don't even need to call operations.BackupDir here, as we already have it in s.backupDir, which we used a few lines earlier:

rclone/fs/sync/sync.go

Lines 385 to 387 in 24fdecf

// If destination already exists, then we must move it into --backup-dir if required
if pair.Dst != nil && s.backupDir != nil {
err := operations.MoveBackupDir(s.ctx, s.backupDir, pair.Dst)

But we may need to do a check to see if src and dst use the same remote and skip it if not.

The list of callers is included on #7566. Probably not all of them will need to be changed, but some of them will. The task is to go through the list and decide which ones need to be changed, and then change them.

@RONGALI-TARUN
Copy link
Author

  1. as i look through the code as far as i understand the function DeleteFileWithBackupDir is specifically created to address when we have provided the --backup-dir or else if we wanted to delete the file itself then we use the function DeleteFile.

Right, to clarify -- the issue is that some functions that are currently calling operations.DeleteFile should really be calling operations.DeleteFileWithBackupDir instead. They may have assumed that they were using the backup-dir because of the incorrect comment on operations.DeleteFile, and now files are not getting backed up when they should be.

Here is an example:

deleteFileErr := operations.DeleteFile(s.ctx, src)

We actually don't even need to call operations.BackupDir here, as we already have it in s.backupDir, which we used a few lines earlier:

rclone/fs/sync/sync.go

Lines 385 to 387 in 24fdecf

// If destination already exists, then we must move it into --backup-dir if required
if pair.Dst != nil && s.backupDir != nil {
err := operations.MoveBackupDir(s.ctx, s.backupDir, pair.Dst)

But we may need to do a check to see if src and dst use the same remote and skip it if not.

The list of callers is included on #7566. Probably not all of them will need to be changed, but some of them will. The task is to go through the list and decide which ones need to be changed, and then change them.

sure will work on this

…o figure out whether they should be obeying --backup-dir found 1 such case
@RONGALI-TARUN
Copy link
Author

md/bisync/bisync_test.go
491: 	return operations.DeleteFile(ctx, obj) ----> this dont require backupDir
cmd/deletefile/deletefile.go
41: 		return operations.DeleteFile(context.Background(), fileObj)  ----> this dont require backupDir
cmd/ncdu/ncdu.go
581: 	err := operations.DeleteFile(ctx, obj) ----> this dont require backupDir
636: 	err = operations.DeleteFile(ctx, obj) ----> this dont require backupDir
fs/operations/dedupe.go
 66: 		err := DeleteFile(ctx, o) ----> this dont require backupDir
130: 	err := DeleteFile(ctx, o) ----> this dont require backupDir
fs/operations/operations.go
 374: 	err = DeleteFile(ctx, dst)
 410: 	return newDst, DeleteFile(ctx, src)
1812: 	err = DeleteFile(ctx, srcObj)
fs/operations/rc.go
276: 	return nil, DeleteFile(ctx, o) ----> this dont require backupDir
fs/sync/sync.go
397: 	s.processError(operations.DeleteFile(s.ctx, src)) -->changed as the src and dst are from same remote
443: 	err = operations.DeleteFile(ctx, src)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants