Skip doing the preflight size calculation in cases where the requested FS operation will be instantaneous anyways.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29093 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2009-01-30 00:08:26 +00:00
parent 994541a836
commit 6a392dcec4
+16 -10
View File
@@ -538,7 +538,7 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *action,
static status_t static status_t
InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread, InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread,
BVolume *dstVol, BDirectory *destDir, entry_ref *destRef, BVolume *dstVol, BDirectory *destDir, entry_ref *destRef,
bool preflightNameCheck, int32 *collisionCount, ConflictCheckResult *preflightResult) bool preflightNameCheck, bool needSizeCalculation, int32 *collisionCount, ConflictCheckResult *preflightResult)
{ {
if (dstVol->IsReadOnly()) { if (dstVol->IsReadOnly()) {
if (gStatusWindow) if (gStatusWindow)
@@ -596,14 +596,16 @@ InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread,
int32 totalItems = 0; int32 totalItems = 0;
off_t totalSize = 0; off_t totalSize = 0;
if (CalcItemsAndSize(srcList, &totalItems, &totalSize) != B_OK) if (needSizeCalculation) {
return B_ERROR; if (CalcItemsAndSize(srcList, &totalItems, &totalSize) != B_OK)
return B_ERROR;
// check for free space before starting copy // check for free space before starting copy
if ((totalSize + (4 * kKBSize)) >= dstVol->FreeBytes()) { if ((totalSize + (4 * kKBSize)) >= dstVol->FreeBytes()) {
(new BAlert("", kNoFreeSpace, "Cancel", 0, 0, (new BAlert("", kNoFreeSpace, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
return B_ERROR; return B_ERROR;
}
} }
if (gStatusWindow) if (gStatusWindow)
@@ -665,7 +667,7 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList, u
bool destIsTrash = false; bool destIsTrash = false;
BDirectory destDir; BDirectory destDir;
BDirectory *destDirToCheck = NULL; BDirectory *destDirToCheck = NULL;
bool needPreflightNameCheck = false; bool needPreflightNameCheck = false;
bool sourceIsReadOnly = volume.IsReadOnly(); bool sourceIsReadOnly = volume.IsReadOnly();
volume.Unset(); volume.Unset();
@@ -711,6 +713,10 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList, u
if (moveMode == kMoveSelectionTo && sourceIsReadOnly) if (moveMode == kMoveSelectionTo && sourceIsReadOnly)
moveMode = kCopySelectionTo; moveMode = kCopySelectionTo;
bool needSizeCalculation = true;
if ((moveMode == kMoveSelectionTo && srcVolumeDevice == destVolumeDevice) || destIsTrash)
needSizeCalculation = false;
// we need the undo object later on, so we create it no matter // we need the undo object later on, so we create it no matter
// if we really need it or not (it's very lightweight) // if we really need it or not (it's very lightweight)
MoveCopyUndo undo(srcList, destDir, pointList, moveMode); MoveCopyUndo undo(srcList, destDir, pointList, moveMode);
@@ -721,7 +727,7 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList, u
ConflictCheckResult conflictCheckResult = kPrompt; ConflictCheckResult conflictCheckResult = kPrompt;
int32 collisionCount = 0; int32 collisionCount = 0;
status_t result = InitCopy(moveMode, srcList, thread, &volume, destDirToCheck, status_t result = InitCopy(moveMode, srcList, thread, &volume, destDirToCheck,
&destRef, needPreflightNameCheck, &collisionCount, &conflictCheckResult); &destRef, needPreflightNameCheck, needSizeCalculation, &collisionCount, &conflictCheckResult);
int32 count = srcList->CountItems(); int32 count = srcList->CountItems();
if (result == B_OK) { if (result == B_OK) {