Skip to content

Commit a05310e

Browse files
committed
Added case for /Application Support/Tox already existing
I tried to get it done without bash… But this was the simplest method that works for this special case scenerio.
1 parent 27fda2e commit a05310e

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

OSX-Migrater.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#!/usr/bin/env bash
22

33
# A qTox profile migrater for OSX
4+
now=$(date +"%m_%d_%Y-%H.%M.%S")
5+
bak="~/.Tox-Backup-$now"
6+
47
echo "Figuring out if action is required ..."
5-
if [ -d ~/Library/Prefrences/tox]
8+
if [ -d ~/Library/Preferences/tox ]; then
69
echo "Moving profile(s) ..."
710
cp -r ~/Library/Preferences/tox ~/Library/Application\ Support/
811
mv ~/Library/Application\ Support/tox/ ~/Library/Application\ Support/Tox
9-
mv ~/Library/Preferences/tox ~/.Tox-Backup
12+
mv ~/Library/Preferences/tox ~/.Tox-Backup-$now
1013
echo "Done! You profile(s) have been moved! A back up coppy still exists at:"
11-
echo "~/.Tox-Backup"
14+
echo "$bak"
1215
else
1316
echo "Cannot locate old profile directory, profile migration not performed"
1417
fi

qtox.pro

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ win32 {
165165
contains(DEFINES, QTOX_PLATFORM_EXT) { LIBS += -framework IOKit -framework CoreFoundation }
166166
contains(DEFINES, QTOX_FILTER_AUDIO) { LIBS += -lfilteraudio }
167167
#Files to be includes into the qTox.app/Contents/Resources folder
168-
APP_RESOURCE.files = img/icons/qtox_profile.icns
168+
#OSX-Migrater.sh part of migrateProfiles() compatabilty code
169+
APP_RESOURCE.files = img/icons/qtox_profile.icns OSX-Migrater.sh
169170
APP_RESOURCE.path = Contents/Resources
170171
QMAKE_BUNDLE_DATA += APP_RESOURCE
171172
#Dynamic versioning for Info.plist

src/platform/install_osx.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void osx::moveToAppFolder()
8484
}
8585
}
8686
}
87-
87+
// migrateProfiles() is compatabilty code that can be removed down the line when the time seems right.
8888
void osx::migrateProfiles()
8989
{
9090
QString oldPath = QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() +
@@ -100,11 +100,20 @@ void osx::migrateProfiles()
100100
qDebug() << "OS X: Old settings directory detected migrating to default";
101101
if( !dir.rename(oldPath, newPath) )
102102
{
103-
qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists.";
103+
qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists. Using alternate migration method.";
104+
QString OSXMigrater = "../Resources/OSX-Migrater.sh" ;
105+
QProcess::execute(OSXMigrater);
106+
QMessageBox MigrateProfile;
107+
MigrateProfile.setIcon(QMessageBox::Information);
108+
MigrateProfile.setWindowModality(Qt::ApplicationModal);
109+
MigrateProfile.setText("Alternate profile migration method used.");
110+
MigrateProfile.setInformativeText("It has been detected that your profiles \nwhere migrated to the new settings directory; \nusing the alternate migration method. \n\nA backup can be found in your: \n/Users/[USER]/.Tox-Backup[DATE-TIME] \n\nJust in case. \r\n");
111+
MigrateProfile.exec();
104112
}
105113
}
106114
else
107115
{
108116
qDebug() << "OS X: Old settings directory not detected";
109117
}
110118
}
119+
// End migrateProfiles() compatibility code

0 commit comments

Comments
 (0)