Permalink
Browse files

Fix up the extension detection for file reversions and also get rid o…

…f the animation for the tray icon, eats up too much CPU.
  • Loading branch information...
1 parent 9b07c66 commit 313f3c86334996c6f18073e5035528bb34f0471b Ken Moore committed Aug 16, 2013
Showing with 25 additions and 11 deletions.
  1. +21 −8 life-preserver/LPBackend.cpp
  2. +4 −3 life-preserver/LPTray.cpp
@@ -224,15 +224,28 @@ QString LPBackend::revertSnapshotFile(QString dsmountpoint, QString snapshot, QS
QString newfilepath = filepath.replace(dsmountpoint+"/.zfs/snapshot/"+snapshot, dsmountpoint);
if( QFile::exists(newfilepath) ){
//get the file extension
- QString ext = newfilepath.section(".",-1);
- newfilepath.chop(ext.length()+1);
- newfilepath.append("-reversion."+ext);
- int i=1;
- //append a number to the end if a reversion file already exists
- while(QFile::exists(newfilepath)){
+ QString filename = newfilepath.section("/",-1);
+ QString ext = filename.section(".",-1);
+ if( !ext.isEmpty() && !filename.startsWith("."+ext) && ext!=filename){
newfilepath.chop(ext.length()+1);
- newfilepath.append(QString::number(i)+"."+ext);
- i++;
+ newfilepath.append("-reversion."+ext);
+ int i=1;
+ //append a number to the end if a reversion file already exists
+ while(QFile::exists(newfilepath)){
+ newfilepath.chop(ext.length()+1);
+ newfilepath.append(QString::number(i)+"."+ext);
+ i ++;
+ }
+ }else{
+ //File without an extension - just append a number
+ newfilepath.append("-reversion");
+ int i=1;
+ QString npath = newfilepath;
+ while(QFile::exists(npath)){
+ npath = newfilepath.append(QString::number(i));
+ i++;
+ }
+ newfilepath = npath;
}
}
//perform the copy
@@ -139,12 +139,13 @@ void LPTray::parseStatusMessage(QString stat){
}
void LPTray::startWorkingIcon(){
- wNum = 1; //start on the first image
- timer->start();
+ this->setIcon( QIcon(":/images/tray-icon-active7.png"));
+ //wNum = 1; //start on the first image
+ //timer->start();
}
void LPTray::stopWorkingIcon(){
- timer->stop();
+ //timer->stop();
this->setIcon( QIcon(":/images/tray-icon-idle.png") );
}

0 comments on commit 313f3c8

Please sign in to comment.