fix bugs
This commit is contained in:
parent
7e1e39e592
commit
f9df723386
|
@ -34,7 +34,7 @@ Files& getFiles(uint64_t fs, std::map<uint64_t, Files>& m) {
|
||||||
void Dedup::start() {
|
void Dedup::start() {
|
||||||
FileIndexer::map_t foundfiles;
|
FileIndexer::map_t foundfiles;
|
||||||
for(const SearchFolder& sf : folders) {
|
for(const SearchFolder& sf : folders) {
|
||||||
foundfiles = indexer.index(sf);
|
foundfiles.merge(indexer.index(sf));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t accFileSize = std::accumulate(foundfiles.begin(), foundfiles.end(), 0ul, [](uint64_t val, auto r){ return val + r.second->filesize; });
|
uint64_t accFileSize = std::accumulate(foundfiles.begin(), foundfiles.end(), 0ul, [](uint64_t val, auto r){ return val + r.second->filesize; });
|
||||||
|
@ -61,10 +61,11 @@ void Dedup::removeUninterestingFiles(std::multimap<uint64_t, std::shared_ptr<Fil
|
||||||
// remove all files with a size of 0
|
// remove all files with a size of 0
|
||||||
files.erase( (const uint64_t& ) 0 );
|
files.erase( (const uint64_t& ) 0 );
|
||||||
|
|
||||||
// remove all files, where they are the only
|
// remove all files, where they are the only one with that size (there cant be any duplicate so no need to hash them)
|
||||||
for(auto it = files.begin(); it != files.end(); ) {
|
for(auto it = files.begin(); it != files.end(); ) {
|
||||||
auto upper = files.upper_bound(it->first);
|
auto upper = files.upper_bound(it->first);
|
||||||
auto next = ++it;
|
auto next = it;
|
||||||
|
++next;
|
||||||
|
|
||||||
// only one file with this filesize
|
// only one file with this filesize
|
||||||
if(next == upper) {
|
if(next == upper) {
|
||||||
|
|
|
@ -81,6 +81,5 @@ void FileIndexer::handleNewFile(ino_t inode, const std::string& path, map_t& new
|
||||||
|
|
||||||
knownInodes.insert(inode);
|
knownInodes.insert(inode);
|
||||||
|
|
||||||
auto file = std::make_shared<File>(fileSize, inode, linkCount, path);
|
newfiles.insert({fileSize, std::make_shared<File>(fileSize, inode, linkCount, path)});
|
||||||
newfiles.insert({fileSize, file});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,11 @@ std::ostream& operator<<(std::ostream& str, const ProgressBar& pb) {
|
||||||
double progress = (pb.currentBytes / (double) pb.maxBytes);
|
double progress = (pb.currentBytes / (double) pb.maxBytes);
|
||||||
|
|
||||||
auto usedtime = pb.getDuration();
|
auto usedtime = pb.getDuration();
|
||||||
std::chrono::duration<uint64_t, std::ratio<60>> eta = std::chrono::duration_cast<std::chrono::minutes>((usedtime / (double) pb.currentBytes) * pb.maxBytes);
|
std::chrono::duration<uint64_t, std::ratio<60>> eta = std::chrono::duration_cast<std::chrono::minutes>((usedtime / (double) pb.currentBytes) * (pb.maxBytes - pb.currentBytes) );
|
||||||
|
|
||||||
// speed
|
// speed
|
||||||
double speed = (pb.currentBytes / (double) usedtime.count()); // B/ms
|
uint64_t usedtimes = std::chrono::duration_cast<std::chrono::seconds>(usedtime).count();
|
||||||
speed /= 1000; // B/s
|
uint64_t speed = (usedtimes != 0) ? (pb.currentBytes / usedtimes) : 0; // B/s
|
||||||
uint64_t bytespersecond = (int) speed; // floor
|
|
||||||
|
|
||||||
// generate bar
|
// generate bar
|
||||||
str << "\r[";
|
str << "\r[";
|
||||||
|
@ -44,7 +43,7 @@ std::ostream& operator<<(std::ostream& str, const ProgressBar& pb) {
|
||||||
str << "] " << std::setprecision(2) << std::setfill('0') << std::fixed << std::setw(5) << (progress * 100) << "% "
|
str << "] " << std::setprecision(2) << std::setfill('0') << std::fixed << std::setw(5) << (progress * 100) << "% "
|
||||||
<< std::setprecision(6) << std::defaultfloat
|
<< std::setprecision(6) << std::defaultfloat
|
||||||
<< FileSize(pb.currentBytes) << '/' << FileSize(pb.maxBytes) << " " << pb.currentFiles << '/' << pb.maxFiles << " Files "
|
<< FileSize(pb.currentBytes) << '/' << FileSize(pb.maxBytes) << " " << pb.currentFiles << '/' << pb.maxFiles << " Files "
|
||||||
<< FileSize(bytespersecond) << "/s ETA: " << eta.count() << "s " << std::flush;
|
<< FileSize(speed) << "/s ETA: " << eta.count() << "min " << std::flush;
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue