Skip to content

Commit

Permalink
Enable sandboxing
Browse files Browse the repository at this point in the history
Note: The system automatically migrates Vienna's library files to a sandbox container on launching Vienna with sandboxing enabled. This can be reversed by using the provided shell script, e.g. for development purposes or for downgrading to an earlier version of Vienna.

The container-migration.plist file specifies the old and new locations for the migration. It should cover all of Vienna's directories and files, so that the user ideally ends up with a complete sandbox container.

Some system-defined locations have to be changed to avoid duplication. For example, Apple moved the cookies storage from ~/Library/Cookies to ~/Library/HTTPStorages starting with macOS 11/Safari 14. Within sandbox containers however, ~/Library/Cookies is used. The automatic migration does not overwrite files. Therefore, a migration of ~/Library/HTTPStorages is attempted first. If that attempt is successful then the migration of ~/Library/Cookies should (silently) fail; otherwise ~/Library/Cookies is migrated instead.

User preferences in ~/Library/Preferences are migrated automatically. User scripts are migrated from ~/Library/Scripts/Applications/Vienna to ~/Library/Application Scripts/<bundle ID> and a symlink is left at the former location; this also happens automatically.

The shell script uses ditto to copy the directories. Ditto will merge directories rather than overwrite them, if the destination directory exists. It will, however, overwrite individual files.
  • Loading branch information
Eitot committed May 29, 2023
1 parent f2e296e commit 30ffdeb
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 34 deletions.
7 changes: 4 additions & 3 deletions Vienna Tests/NSFileManagerExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class NSFileManagerExtensionTests: XCTestCase {

func testApplicationScriptsPath() throws {
let result = FileManager.default.applicationScriptsDirectory
let fullPath = "\(homePath)/Library/Scripts/Applications/Vienna"
let bundleID = try XCTUnwrap(bundleID)
let fullPath = "\(homePath)/Library/Application Scripts/\(bundleID)"
XCTAssertEqual(result.path, fullPath)
}

func testApplicationSupportPath() throws {
func testApplicationSupportPath() {
let result = FileManager.default.applicationSupportDirectory
let fullPath = "\(homePath)/Library/Application Support/Vienna"
XCTAssertEqual(result.path, fullPath)
Expand All @@ -43,7 +44,7 @@ class NSFileManagerExtensionTests: XCTestCase {
XCTAssertEqual(result.path, fullPath)
}

func testDownloadsPath() throws {
func testDownloadsPath() {
let result = FileManager.default.downloadsDirectory
let fullPath = "\(homePath)/Downloads"
XCTAssertEqual(result.path, fullPath)
Expand Down
20 changes: 14 additions & 6 deletions Vienna.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
F6164C591E32A6660086261C /* DisclosureView.m in Sources */ = {isa = PBXBuildFile; fileRef = F6164C581E32A6660086261C /* DisclosureView.m */; };
F61CEA661F039E57009C878E /* ButtonToolbarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F61CEA651F039E56009C878E /* ButtonToolbarItem.swift */; };
F61CEA681F03F277009C878E /* PlugInToolbarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F61CEA671F03F277009C878E /* PlugInToolbarItem.swift */; };
F6209C4423D3B87C00D5537D /* container-migration.plist in Resources */ = {isa = PBXBuildFile; fileRef = F6209C4323D3B87C00D5537D /* container-migration.plist */; };
F6209C5A23D3FFA700D5537D /* Vienna.sdef in Resources */ = {isa = PBXBuildFile; fileRef = F6209C5923D3FFA700D5537D /* Vienna.sdef */; };
F6257FF51E28485F0035E43C /* Downloads.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6257FF71E28485F0035E43C /* Downloads.xib */; };
F625801C1E2853B90035E43C /* ActivityViewer.xib in Resources */ = {isa = PBXBuildFile; fileRef = F625801E1E2853B90035E43C /* ActivityViewer.xib */; };
Expand Down Expand Up @@ -213,6 +214,7 @@
F6B355DB256025D3008CA1ED /* PreferenceTabViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6B355DA256025D3008CA1ED /* PreferenceTabViewItem.swift */; };
F6B3561525616313008CA1ED /* DownloadItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F6B3561425616313008CA1ED /* DownloadItem.m */; };
F6B7BC3624A2A9A40051D76F /* FMDB in Frameworks */ = {isa = PBXBuildFile; productRef = F6B7BC3524A2A9A40051D76F /* FMDB */; };
F6C9B03A26E6F3E0003C1058 /* undo-container-migration.sh in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = F668C10E26886CB6009AD505 /* undo-container-migration.sh */; };
F6C9DA70271BB3BB00FC3027 /* RSSFeed.m in Sources */ = {isa = PBXBuildFile; fileRef = F6C9DA6F271BB3BB00FC3027 /* RSSFeed.m */; };
F6C9DA73271BB55000FC3027 /* AtomFeed.m in Sources */ = {isa = PBXBuildFile; fileRef = F6C9DA72271BB55000FC3027 /* AtomFeed.m */; };
F6CE47131E7E3DCB0045EAD7 /* ActivityItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F6CE47121E7E3DCB0045EAD7 /* ActivityItem.m */; };
Expand Down Expand Up @@ -271,6 +273,7 @@
files = (
B27CD00C1100E728001F3C83 /* Plugins in Copy Shared Support Files */,
AA67F353089728AD008BBC37 /* Styles in Copy Shared Support Files */,
F6C9B03A26E6F3E0003C1058 /* undo-container-migration.sh in Copy Shared Support Files */,
);
name = "Copy Shared Support Files";
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -360,8 +363,8 @@
3A7BD0DB1989AC7700E9444B /* VNAVerticallyCenteredTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VNAVerticallyCenteredTextFieldCell.h; sourceTree = "<group>"; };
3A7BD0DC1989AC7700E9444B /* VNAVerticallyCenteredTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VNAVerticallyCenteredTextFieldCell.m; sourceTree = "<group>"; };
3A8D9AE225A9DA4B0016F30F /* ArticleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArticleTests.swift; sourceTree = "<group>"; };
3A932D8823BB999A009B8061 /* Vienna.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Vienna.entitlements; sourceTree = "<group>"; };
3A932D8923BB999A009B8061 /* ViennaDeployment.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = ViennaDeployment.entitlements; sourceTree = "<group>"; };
3A932D8823BB999A009B8061 /* Development.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Development.entitlements; sourceTree = "<group>"; };
3A932D8923BB999A009B8061 /* Deployment.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Deployment.entitlements; sourceTree = "<group>"; };
3AC411A426BBFDFD004A8700 /* WebKitArticleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebKitArticleView.swift; sourceTree = "<group>"; };
3ADBA70C23DDAFCA00156722 /* Notarize.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = Notarize.sh; sourceTree = "<group>"; };
3AEE7DE81695FC570018A17D /* SparkleDSAPublicKey.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SparkleDSAPublicKey.pem; sourceTree = "<group>"; };
Expand Down Expand Up @@ -522,6 +525,7 @@
F6167E6B209EFE370006E2C4 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = pt; path = pt.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
F61CEA651F039E56009C878E /* ButtonToolbarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ButtonToolbarItem.swift; sourceTree = "<group>"; };
F61CEA671F03F277009C878E /* PlugInToolbarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = PlugInToolbarItem.swift; sourceTree = "<group>"; };
F6209C4323D3B87C00D5537D /* container-migration.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "container-migration.plist"; sourceTree = "<group>"; };
F6209C5923D3FFA700D5537D /* Vienna.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; lineEnding = 0; path = Vienna.sdef; sourceTree = "<group>"; usesTabs = 1; };
F62116A9209EFE9F00FAC2C2 /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = uk; path = uk.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
F6257FF61E28485F0035E43C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Downloads.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -695,6 +699,7 @@
F658FD8D209EFE5100896413 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ru; path = ru.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
F65F2313294E4B5200605F06 /* SeparatorPredicateEditorRowTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeparatorPredicateEditorRowTemplate.swift; sourceTree = "<group>"; };
F664A9A2209EFEBF003B0F7D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.stringsdict"; sourceTree = "<group>"; };
F668C10E26886CB6009AD505 /* undo-container-migration.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; lineEnding = 0; path = "undo-container-migration.sh"; sourceTree = "<group>"; };
F66A7E542A019006002F5D5E /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Predicates.strings; sourceTree = "<group>"; };
F672876624A2D20A0043432F /* UpdatePreferencesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UpdatePreferencesViewController.h; sourceTree = "<group>"; };
F672876724A2D2170043432F /* UpdatePreferencesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UpdatePreferencesViewController.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1262,6 +1267,7 @@
F63DA1741F1CF04F007CBED4 /* Lists */,
F63DA1721F1CEFC3007CBED4 /* Strings */,
03F33D951DF2A2F900B04FAF /* Assets.xcassets */,
F6209C4323D3B87C00D5537D /* container-migration.plist */,
F6209C5923D3FFA700D5537D /* Vienna.sdef */,
3AEE7DE81695FC570018A17D /* SparkleDSAPublicKey.pem */,
);
Expand Down Expand Up @@ -1294,6 +1300,7 @@
children = (
B27CCFFD1100E728001F3C83 /* Plugins */,
AA67F32E089727FB008BBC37 /* Styles */,
F668C10E26886CB6009AD505 /* undo-container-migration.sh */,
);
path = SharedSupport;
sourceTree = "<group>";
Expand Down Expand Up @@ -1424,8 +1431,8 @@
F63DA16E1F1CEC69007CBED4 /* Resources */,
F63DA1751F1CF182007CBED4 /* SharedSupport */,
430C4AE0166175C20079C9FC /* Info.plist */,
3A932D8823BB999A009B8061 /* Vienna.entitlements */,
3A932D8923BB999A009B8061 /* ViennaDeployment.entitlements */,
3A932D8823BB999A009B8061 /* Development.entitlements */,
3A932D8923BB999A009B8061 /* Deployment.entitlements */,
3A6CC18623BBA49D0084ABEE /* Codesigning.xcconfig */,
);
path = Vienna;
Expand Down Expand Up @@ -1863,6 +1870,7 @@
F62580AA1E286A8C0035E43C /* Localizable.strings in Resources */,
F6832F631F10C4C9007920D4 /* ExportAccessoryViewController.xib in Resources */,
AACAEA3E0954E71100ACD502 /* DemoFeeds.plist in Resources */,
F6209C4423D3B87C00D5537D /* container-migration.plist in Resources */,
F65D6D711E74619E00A30974 /* Credits.rtf in Resources */,
F685D24C292460210097C0D3 /* Predicates.strings in Resources */,
F69AE79A1F2215D600342640 /* InfoPlist.strings in Resources */,
Expand Down Expand Up @@ -3102,7 +3110,7 @@
buildSettings = {
APPLY_RULES_IN_COPY_FILES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Vienna/Vienna.entitlements;
CODE_SIGN_ENTITLEMENTS = Vienna/Development.entitlements;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -3148,7 +3156,7 @@
buildSettings = {
APPLY_RULES_IN_COPY_FILES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Vienna/ViennaDeployment.entitlements;
CODE_SIGN_ENTITLEMENTS = Vienna/Deployment.entitlements;
COMBINE_HIDPI_IMAGES = YES;
DEPLOYMENT_POSTPROCESSING = YES;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.files.bookmarks.app-scope</key>
<true/>
<key>com.apple.security.files.downloads.read-write</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spks</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.files.bookmarks.app-scope</key>
<true/>
<key>com.apple.security.files.downloads.read-write</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spks</string>
Expand Down
2 changes: 1 addition & 1 deletion Vienna/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<key>SUEnableAutomaticChecks</key>
<true/>
<key>SUEnableInstallerLauncherService</key>
<false/>
<true/>
<key>SUPublicDSAKeyFile</key>
<string>SparkleDSAPublicKey.pem</string>
<key>SUPublicEDKey</key>
Expand Down
39 changes: 39 additions & 0 deletions Vienna/Resources/container-migration.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MigrateScriptsForApplication</key>
<string>Vienna</string>
<key>Move</key>
<array>
<array>
<string>${Caches}/${BundleId}/WebKit</string>
<string>${Caches}/WebKit</string>
</array>
<string>${Caches}/${BundleId}</string>
<array>
<string>${ApplicationSupport}/Vienna/Sources</string>
<string>${Caches}/${BundleId}/Sources</string>
</array>
<string>${ApplicationSupport}/Vienna</string>
<string>${Library}/HTTPStorages/${BundleId}</string>
<array>
<string>${Library}/HTTPStorages/${BundleId}.binarycookies</string>
<string>${Library}/Cookies/Cookies.binarycookies</string>
</array>
<array>
<string>${Library}/Cookies/${BundleId}.binarycookies</string>
<string>${Library}/Cookies/Cookies.binarycookies</string>
</array>
<string>${Library}/Saved Application State/${BundleId}.savedState</string>
<array>
<string>${Library}/WebKit/${BundleId}</string>
<string>${Library}/WebKit</string>
</array>
<array>
<string>${Library}/WebKit/Databases/___IndexedDB/${BundleId}</string>
<string>${Library}/WebKit/Databases/___IndexedDB</string>
</array>
</array>
</dict>
</plist>
161 changes: 161 additions & 0 deletions Vienna/SharedSupport/undo-container-migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#!/bin/sh
#
# undo-container-migration.sh
# Vienna
#
# Copyright 2021-2022 Eitot
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

LIBRARY="$HOME/Library"
BUNDLE_ID='uk.co.opencommunity.vienna2'
CONTAINER="$LIBRARY/Containers/$BUNDLE_ID"
CONTAINER_LIBRARY="$CONTAINER/Data/Library"

set -e

if [ ! -d "$CONTAINER" ]
then
printf 'No sandbox container found for Vienna\n' >&2
exit 1
fi

if [ -n "$(killall -s Vienna 2>/dev/null)" ]
then
printf 'Please quit Vienna and try again\n' >&2
exit 1
fi

printf 'This script attempts to undo the container migration. Use this only to '
printf 'revert to an older version of Vienna that does not support sandboxing. '
printf 'Please make sure that Vienna is not opened during this process.\n'

tput bold
printf 'Are you sure you want to do this? [y/N] '
tput sgr0
read -r
if ! printf '%s' "$REPLY" | grep -q -E '^[Yy]$'
then
exit 1
fi

# Configure ditto to use verbose mode and abort if encountering a fatal error.
alias ditto='ditto -v'
export DITTOABORT=1

# User scripts are located in ~/Library/Application Scripts/<bundle ID> instead
# of the sandbox container when sandboxing is enabled. Without sandboxing, they
# are located in ~/Library/Scripts/Applications/<app name>. A symlink was added
# at that location as a result of the automatic migration.
if [ -L "$LIBRARY/Scripts/Applications/Vienna" ]
then
unlink "$LIBRARY/Scripts/Applications/Vienna" \
&& printf 'Cleared %s\n' "$LIBRARY/Scripts/Applications/Vienna"
fi

if [ -d "$LIBRARY/Application Scripts/$BUNDLE_ID" ]
then
ditto "$LIBRARY/Application Scripts/$BUNDLE_ID" \
"$LIBRARY/Scripts/Applications/Vienna"
rm -r "$LIBRARY/Application Scripts/$BUNDLE_ID" \
&& printf 'Deleted %s\n' "$LIBRARY/Application Scripts/$BUNDLE_ID"
fi

if [ -d "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB" ]
then
ditto "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB" \
"$LIBRARY/WebKit/Databases/___IndexedDB/$BUNDLE_ID"
rm -r "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB" \
&& printf 'Deleted %s\n' "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB"
fi

if [ -d "$CONTAINER_LIBRARY/WebKit" ]
then
ditto "$CONTAINER_LIBRARY/WebKit" "$LIBRARY/WebKit/$BUNDLE_ID"
fi

if [ -d "$CONTAINER_LIBRARY/Saved Application State/$BUNDLE_ID.savedState" ]
then
ditto "$CONTAINER_LIBRARY/Saved Application State/$BUNDLE_ID.savedState" \
"$LIBRARY/Saved Application State/$BUNDLE_ID.savedState"
fi

# Preferences are not explicitely declared in the migration manifest file; the
# behaviour is implicit.
if [ -f "$CONTAINER_LIBRARY/Preferences/$BUNDLE_ID.plist" ]
then
ditto "$CONTAINER_LIBRARY/Preferences/$BUNDLE_ID.plist" \
"$LIBRARY/Preferences/$BUNDLE_ID.plist"
fi

# The location of cookies files of non-sandboxed applications changed from
# ~/Library/Cookies to ~/Library/HTTPStorages as of macOS 11 (and probably
# Safari 14).
MACOS_VERSION="$(sw_vers -productVersion)"
MACOS_MAJOR_VERSION="${MACOS_VERSION%%.*}"

if [ "$MACOS_MAJOR_VERSION" -ge 11 ] || [ -d "$LIBRARY/HTTPStorages" ]
then
if [ -f "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" ]
then
ditto "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" \
"$LIBRARY/HTTPStorages/$BUNDLE_ID.binarycookies"
fi
else
if [ -f "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" ]
then
ditto "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" \
"$LIBRARY/Cookies/$BUNDLE_ID.binarycookies"
fi
fi

if [ -d "$CONTAINER_LIBRARY/HTTPStorages/$BUNDLE_ID" ]
then
ditto "$CONTAINER_LIBRARY/HTTPStorages/$BUNDLE_ID" \
"$LIBRARY/HTTPStorages/$BUNDLE_ID"
fi

if [ -d "$CONTAINER_LIBRARY/Application Support/Vienna" ]
then
ditto "$CONTAINER_LIBRARY/Application Support/Vienna" \
"$LIBRARY/Application Support/Vienna"
fi

# The Sources subdirectory was moved from Library/Application Support to
# Library/Caches.
if [ -d "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources" ]
then
ditto "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources" \
"$LIBRARY/Application Support/Vienna/Sources"
rm -r "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources" \
&& printf 'Deleted %s\n' "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources"
fi

# The WebKit subdirectory in Library/Caches used to be located within the app's
# caches directory (Library/Caches/<bundle ID>/WebKit).
if [ -d "$CONTAINER_LIBRARY/Caches/WebKit" ]
then
ditto "$CONTAINER_LIBRARY/Caches/WebKit" \
"$LIBRARY/Caches/$BUNDLE_ID/WebKit"
rm -r "$CONTAINER_LIBRARY/Caches/WebKit" \
&& printf 'Deleted %s\n' "$CONTAINER_LIBRARY/Caches/WebKit"
fi

if [ -d "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID" ]
then
ditto "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID" "$LIBRARY/Caches/$BUNDLE_ID"
fi

osascript -e "tell application \"Finder\" to delete POSIX file \"$CONTAINER\"" \
1>/dev/null && printf 'Trashed %s\n' "$CONTAINER"
4 changes: 2 additions & 2 deletions Vienna/Sources/Preferences window/Preferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ -(instancetype)init
// Application-specific folder locations
defaultDatabase = [userPrefs stringForKey:MAPref_DefaultDatabase];
NSFileManager *fileManager = NSFileManager.defaultManager;
NSString *appSupportPath = fileManager.vna_applicationSupportDirectory.path;
feedSourcesFolder = [appSupportPath stringByAppendingPathComponent:MA_FeedSourcesFolder_Name];
NSString *cachesPath = fileManager.vna_cachesDirectory.path;
feedSourcesFolder = [cachesPath stringByAppendingPathComponent:MA_FeedSourcesFolder_Name];

// Load those settings that we cache.
foldersTreeSortMethod = [self integerForKey:MAPref_AutoSortFoldersTree];
Expand Down
Loading

0 comments on commit 30ffdeb

Please sign in to comment.