DiskUsage: remove path monitoring and "outdated view" notification

Was unreliable, too many files to monitor (would exceed too easily the 4096 files limit).
This commit is contained in:
Philippe Saint-Pierre 2012-11-03 11:58:47 -04:00
parent 08282eb476
commit a4ef1e81ce
5 changed files with 3 additions and 121 deletions

View File

@ -61,7 +61,6 @@ extern bool helpFileWasFound;
#define kScanRefresh 'gSRF' #define kScanRefresh 'gSRF'
#define kScanProgress 'gSPR' #define kScanProgress 'gSPR'
#define kScanDone 'gSDN' #define kScanDone 'gSDN'
#define kOutdatedMsg 'gOUT'
#define deg2rad(x) (2.0 * M_PI * (x) / 360.0) #define deg2rad(x) (2.0 * M_PI * (x) / 360.0)
#define rad2deg(x) (360.0 * (x) / (2.0 * M_PI)) #define rad2deg(x) (360.0 * (x) / (2.0 * M_PI))

View File

@ -135,8 +135,7 @@ PieView::PieView(BVolume* volume)
fVolume(volume), fVolume(volume),
fMouseOverInfo(), fMouseOverInfo(),
fClicked(false), fClicked(false),
fDragging(false), fDragging(false)
fOutdated(false)
{ {
fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false); fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false);
fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Get Info"), NULL), fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Get Info"), NULL),
@ -188,7 +187,6 @@ PieView::MessageReceived(BMessage* message)
else else
_ShowVolume(fVolume); _ShowVolume(fVolume);
fOutdated = false;
Invalidate(); Invalidate();
} }
break; break;
@ -200,15 +198,6 @@ PieView::MessageReceived(BMessage* message)
break; break;
} }
case kOutdatedMsg:
{
if (!fScanner->IsBusy()) {
fOutdated = true;
Invalidate();
}
break;
}
default: default:
BView::MessageReceived(message); BView::MessageReceived(message);
break; break;
@ -250,11 +239,9 @@ PieView::MouseUp(BPoint where)
if (info != NULL) { if (info != NULL) {
if (info == fScanner->CurrentDir()) { if (info == fScanner->CurrentDir()) {
fScanner->ChangeDir(info->parent); fScanner->ChangeDir(info->parent);
fOutdated = fScanner->IsOutdated();
Invalidate(); Invalidate();
} else if (info->children.size() > 0) { } else if (info->children.size() > 0) {
fScanner->ChangeDir(info); fScanner->ChangeDir(info);
fOutdated = fScanner->IsOutdated();
Invalidate(); Invalidate();
} }
} }
@ -415,21 +402,6 @@ PieView::_DrawPieChart(BRect updateRect)
} }
_DrawDirectory(pieRect, currentDir, 0.0, 0.0, _DrawDirectory(pieRect, currentDir, 0.0, 0.0,
colorIdx % kBasePieColorCount, 0); colorIdx % kBasePieColorCount, 0);
if (fOutdated) {
BRect b = Bounds();
float strWidth = StringWidth(B_TRANSLATE("Outdated view"));
float bx = (b.Width() - strWidth - kSmallHMargin);
struct font_height fh;
be_plain_font->GetHeight(&fh);
float by = (b.Height() - ceil(fh.descent) - kSmallVMargin);
SetHighColor(0x00, 0x00, 0x00);
DrawString(B_TRANSLATE("Outdated view"), BPoint(bx, by));
}
} }

View File

@ -92,7 +92,6 @@ private:
bool fDragging; bool fDragging;
BPoint fDragStart; BPoint fDragStart;
FileInfo* fClickedFile; FileInfo* fClickedFile;
bool fOutdated;
}; };
#endif // PIE_VIEW_H #endif // PIE_VIEW_H

View File

@ -15,7 +15,6 @@
#include <Catalog.h> #include <Catalog.h>
#include <Directory.h> #include <Directory.h>
#include <PathMonitor.h>
#include "DiskUsage.h" #include "DiskUsage.h"
@ -36,9 +35,7 @@ Scanner::Scanner(BVolume *v, BHandler *handler)
fDesiredPath(), fDesiredPath(),
fTask(), fTask(),
fBusy(false), fBusy(false),
fQuitRequested(false), fQuitRequested(false)
fIsWatching(false),
fModifiedEntries()
{ {
Run(); Run();
} }
@ -46,17 +43,7 @@ Scanner::Scanner(BVolume *v, BHandler *handler)
Scanner::~Scanner() Scanner::~Scanner()
{ {
if (fIsWatching) {
BPrivate::BPathMonitor::StopWatching(BMessenger(this, this));
fIsWatching = false;
}
delete fSnapshot; delete fSnapshot;
while (fModifiedEntries.size() != 0) {
entry_ref* entry = *fModifiedEntries.begin();
delete entry;
fModifiedEntries.erase(fModifiedEntries.begin());
}
} }
@ -73,38 +60,6 @@ Scanner::MessageReceived(BMessage* message)
break; break;
} }
case B_PATH_MONITOR:
{
dev_t device;
ino_t directory;
const char* name = "";
const char* path;
if (((message->FindInt32("device", &device) != B_OK)
|| (message->FindInt64("directory", &directory) != B_OK)
|| (message->FindString("name", &name) != B_OK))
&& ((message->FindString("path", &path) != B_OK)
|| (message->FindInt32("device", &device) != B_OK)))
return;
entry_ref* reportedEntry;
if (strlen(name) > 0)
reportedEntry = new entry_ref(device, directory, name);
else {
BEntry entry(path);
reportedEntry = new entry_ref();
entry.GetRef(reportedEntry);
}
fModifiedEntries.push_back(reportedEntry);
if (IsOutdated()) {
BMessage msg(kOutdatedMsg);
fListener.SendMessage(&msg);
}
break;
}
default: default:
BLooper::MessageReceived(message); BLooper::MessageReceived(message);
break; break;
@ -120,12 +75,6 @@ Scanner::Refresh(FileInfo* startInfo)
fBusy = true; fBusy = true;
while (fModifiedEntries.size() != 0) {
entry_ref* entry = *fModifiedEntries.begin();
delete entry;
fModifiedEntries.erase(fModifiedEntries.begin());
}
// Remember the current directory, if any, so we can return to it after // Remember the current directory, if any, so we can return to it after
// the scanning is done. // the scanning is done.
if (fSnapshot != NULL && fSnapshot->currentDir != NULL) if (fSnapshot != NULL && fSnapshot->currentDir != NULL)
@ -165,27 +114,6 @@ Scanner::RequestQuit()
} }
bool
Scanner::IsOutdated()
{
FileInfo* currentDir = (fSnapshot->currentDir != NULL ?
fSnapshot->currentDir : fSnapshot->rootDir);
BDirectory currentDirectory(&(currentDir->ref));
bool isOutdated = currentDirectory.InitCheck() != B_OK;
vector<entry_ref*>::iterator i = fModifiedEntries.begin();
while (!isOutdated && i != fModifiedEntries.end()) {
BEntry entry(*i);
isOutdated = _DirectoryContains(currentDir, *i)
|| currentDirectory.Contains(&entry);
i++;
}
return isOutdated;
}
// #pragma mark - private // #pragma mark - private
@ -260,16 +188,6 @@ Scanner::_RunScan(FileInfo* startInfo)
} }
} }
if (!fIsWatching) {
string path;
fSnapshot->rootDir->GetPath(path);
BPrivate::BPathMonitor::StartWatching(path.c_str(),
B_WATCH_ALL | B_WATCH_RECURSIVELY, BMessenger(this, this));
fIsWatching = true;
}
fBusy = false; fBusy = false;
_ChangeToDesired(); _ChangeToDesired();
fListener.SendMessage(&fDoneMessage); fListener.SendMessage(&fDoneMessage);

View File

@ -11,7 +11,6 @@
#include <string> #include <string>
#include <vector>
#include <Looper.h> #include <Looper.h>
#include <Message.h> #include <Message.h>
@ -50,7 +49,6 @@ public:
dev_t Device() const dev_t Device() const
{ return fVolume->Device(); } { return fVolume->Device(); }
void RequestQuit(); void RequestQuit();
bool IsOutdated();
private: private:
void _RunScan(FileInfo *startInfo); void _RunScan(FileInfo *startInfo);
@ -73,10 +71,6 @@ private:
string fTask; string fTask;
bool fBusy; bool fBusy;
bool fQuitRequested; bool fQuitRequested;
bool fIsWatching;
std::vector<entry_ref*> fModifiedEntries;
}; };
#endif // SCANNER_H #endif // SCANNER_H