diff --git a/TimeZones-v2.13.zip b/TimeZones-v2.13.zip
deleted file mode 100644
index 35f73c7..0000000
Binary files a/TimeZones-v2.13.zip and /dev/null differ
diff --git a/TimeZones-v2.12.zip b/TimeZones-v2.14.zip
similarity index 77%
rename from TimeZones-v2.12.zip
rename to TimeZones-v2.14.zip
index 357660b..b28c200 100644
Binary files a/TimeZones-v2.12.zip and b/TimeZones-v2.14.zip differ
diff --git a/source/includes.sh b/source/includes.sh
index dae72f0..03569e2 100755
--- a/source/includes.sh
+++ b/source/includes.sh
@@ -1,14 +1,9 @@
-#includes for TimeZones scripts
-
-#Working Directories
-TZPREFS="$alfred_workflow_data"
-
-CONFIG_EXTRA="$TZPREFS/configExtra"
+#!/usr/bin/env bash
function migratePreferece() {
LEGACY_TZPREFS="$HOME/Library/Application Support/Alfred 3/Workflow Data/carlosnz.timezones"
[[ ! -d "$TZPREFS" ]] && mkdir -p "$TZPREFS" 2>/dev/null
- [[ ! -e "$TZPREFS/timezones.txt" ]] && cp "$LEGACY_TZPREFS/"* "$TZPREFS/" 2>/dev/null
+ [[ ! -e "$timezone_file" ]] && cp "$LEGACY_TZPREFS/"* "$TZPREFS/" 2>/dev/null
[[ -e "$TZPREFS/config-1-5" ]] && rm "$TZPREFS/config-1-5" 2>/dev/null
}
@@ -33,15 +28,24 @@ function getPreference() {
echo "$VALUE"
}
+#Working Directories
+#includes for TimeZones scripts
+TZPREFS="$alfred_workflow_data"
+CONFIG_EXTRA="$TZPREFS/configExtra"
+TIMEZONE_PATH="$(getPreference 'TIMEZONE_PATH' "$TZPREFS" )"
+
+#Load path to the user's timezones.txt file.
+timezone_file="$TIMEZONE_PATH/timezones.txt"
+
+# echo "$TIMEZONE_PATH" >> /tmp/bzz
+# ls -l "$TIMEZONE_PATH" >> /tmp/bzz
+
#Enable aliases for this script
shopt -s expand_aliases
#Case-insensitive matching
shopt -s nocasematch
-#Load path to the user's timezones.txt file.
-timezone_file="$TZPREFS/timezones.txt"
-
migratePreferece
#Does the file actually exist?
diff --git a/source/info.plist b/source/info.plist
index c53aafc..5eef190 100644
--- a/source/info.plist
+++ b/source/info.plist
@@ -721,7 +721,7 @@
subtext
Results will not be sorted and will follow order from timezones.txt
text
- Disable result ordering
+ Disable result sorting
withspace
@@ -807,9 +807,9 @@
keyword
timezone sort on
subtext
- Results will not sorted with Favourites on the top
+ Results will be sorted with Favourites on the top
text
- Enable result ordering
+ Enable result sorting
withspace
@@ -887,8 +887,8 @@
readme
- TimeZones v2.13
-14 August 2019
+ TimeZones v2.14
+1 September 2019
@@ -934,6 +934,11 @@ CHANGELOG
All issues tracked on GitHub https://github.com/jaroslawhartman/TimeZones-Alfred/issues
+v2.14
+1 September 2019
+* Reverted handling of Dropbox timezones.txt (#23)
+* Asking wheither override when an existing timezones.txt in the new location (#27)
+
v2.13
26 August 2019
* Fixed an issue when more than 7 TimeZones (#28)
@@ -1250,7 +1255,7 @@ v1.0
version
- 2.13
+ 2.14
webaddress
https://jhartman.pl/tag/time-zones/
diff --git a/source/move.sh b/source/move.sh
index 502848c..5349f11 100755
--- a/source/move.sh
+++ b/source/move.sh
@@ -12,23 +12,46 @@ end tell
EOF)
-if [ -z $user_path ]; then
+if [[ -z "${user_path}" ]]; then
exit
fi
-#Move timezones.txt
-mv "$timezone_file" "$user_path"
+yes_no="override"
+
+# Check if timezones.txt exists in the target
+# Ask if override
+if [[ -e "${user_path}/timezones.txt" ]]
+then
+ yes_no=$(osascript <<-EOF
+ tell application "System Events"
+ activate
+ display alert "A timezones.txt exists in the new location.\nUse config from the new location or override it by the current config?" buttons {"New location", "Override"}
+
+ if button returned of result = "Override" then
+ return "override"
+ end if
+ end tell
+ EOF)
+fi
+
+if [[ "$yes_no" == "override" ]]
+then
+ #Move timezones.txt
+ cp "$timezone_file" "$user_path"
+ result="$?"
+else
+ result=0
+fi
#If file operation successful
-if [ $? = 0 ]; then
- #Update config file with new path
- echo "$user_path/timezones.txt" > "$TZPREFS/config-1-5"
+if [[ $result = 0 ]]; then
+ storePreference "TIMEZONE_PATH" "$user_path"
#Notify
- echo -n "File successfully moved to new location."
+ echo -n "Using timezones.txt file from $user_path."
else
#Notify
- echo -n "Sorry, unable to move to that location."
+ echo -n "Sorry, unable to move to that location $user_path."
fi
exit
\ No newline at end of file