Opened 16 years ago

Closed 16 years ago

#1147 closed defect (fixed)

Incorrect result from isUsed() method prevents deletion of some items

Reported by: Jari Häkkinen Owned by: Nicklas Nordborg
Priority: minor Milestone: BASE 2.8.4
Component: web Version: 2.8.3
Keywords: Cc:

Description

The trashcan view shows the dependency icon for the item but clicking on the icon to find out what is blocking removal there is nothing. (It is shared to a project but even if the sharing is removed nothing is resolved.) Going back to the trashcan view, selecting the item and clicking on the 'delete permanently' button will not work. However, clicking on the dependency icon, and in the detailed view of the item clicking on the 'delete permanently' button actually removes the item!

Change History (7)

comment:1 by Jari Häkkinen, 16 years ago

Why is there a dependency icon at the first place? There is no dependency icon in the detailed view of the deleted item (i.e. the view that appears when the dependency icon is clicked).

comment:2 by Nicklas Nordborg, 16 years ago

Could it be that someone else has deleted the dependency while you were clicking around? The icon is always the result of calling Directory.isUsed() so it should be consistent on all pages. The list of items could differ due to bugs, because the list is generated by Directory.getUsingItems(), but as far as I can see the code in those two methods should agree.

In any case, simply creating a directory and deleting it, doesn't reproduces the issue. Do you have any information that can make this reproducable?

comment:3 by Jari Häkkinen, 16 years ago

I am sure that no one else made any change during my tests because I made som many tests before reporting this that the chance that random unlinks would happen is small. I'll try to create a recipe that reproduce this problem. This is a problem coupled with most of the BASE1 plugins. Maybe you should install one of them run it and start deleteing. I'll come back with more details when I can reproduce the problem in my machine.

comment:4 by Jari Häkkinen, 16 years ago

Come to think of it, these directories are created by a failed job. The underlying BASE1 plugin fails, parts of files are generated. The Base1PluginExecuter does not catch the failure since the BASE1 plugin does not report success nor failure. Maybe it does not mean anything for the problem but thought I should mention it.

comment:5 by Nicklas Nordborg, 16 years ago

Priority: majorminor
Summary: Removing directories from trashcan fails even if no depenency existsIncorrect result from isUsed() method prevents deletion of some items

I think I can explain this and it is possible to reproduce with the TestBase1PluginExecuter program.

  1. Execute ./run.sh TestBase1PluginExecuter -w
  2. When the Press ENTER to continue... text appears, log in with the web interface and locate the directories/files created by the test program. They should be in /Base1PluginExecuter.
  3. Select one or two of the directories and click on the Delete button.
  4. Move to the trashcan: View -> Trashcan
  5. You should find all directories and files that you deleted in step 3. All should have the the item icon with a chain that indicates that the are used.
  6. Select a file and click on the Delete permanently button. The file is not deleted.
  7. Click on the chained icon for the same file.
  8. The page that is displayed is supposed to show the items that are blocking the deletion of the file, but the list is empty.
  9. Click on the Delete permanently. The file is now deleted.

Clearly something is not working as expected here.

  1. There is obviously a discrepancy between the result from the File.isUsed() and File.getUsingItems() methods. After checking the code it seems like the error is in the File.isUsed() method which uses the incorrect SQL to check if there are AnyToAny links using the file. The query checks all links, not just the ones with the isUsing flag set. In other words, the list page of step 8 is correct, the chained icon in the main Trashcan list should never have been there.
  2. The above doesn't explain why the file can be deleted in step 9. The DbControl.commit() method checks the result from the isUsed() method before trying to delete the file. But, just a few lines before this check is done, a call is made to a routine that deletes all AnyToAny links from the file. This changes the result from the isUsed() method, and the file gets deleted. The reason that the file is not deleted in step 6 is that the "smartness" of the Trashcan also calls isUsed() before trying to delete an item. This is done before the cleanup of AnyToAny links and the file can't be deleted. In both cases, the problem is the incorrect result from the isUsed() method.

comment:6 by Nicklas Nordborg, 16 years ago

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:7 by Nicklas Nordborg, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [4591]) Fixes #1147: Incorrect result from isUsed() method prevents deletion of some items

Note: See TracTickets for help on using tickets.