Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for accessing public folder from extensions #96

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/AppInstallerCommonCore/ExtensionCatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once
#include "pch.h"
#include "winget/ExtensionCatalog.h"
#include "AppInstallerErrors.h"
#include "AppInstallerLogging.h"
#include "AppInstallerStrings.h"

Expand All @@ -19,7 +20,9 @@ namespace AppInstaller::Deployment

std::filesystem::path Extension::GetPublicFolderPath() const
{
return m_extension.GetPublicFolderAsync().get().Path().c_str();
auto folder = m_extension.GetPublicFolderAsync().get();
THROW_HR_IF(APPINSTALLER_CLI_ERROR_EXTENSION_PUBLIC_FAILED, !folder);
return folder.Path().c_str();
}

winrt::Windows::ApplicationModel::PackageVersion Extension::GetPackageVersion() const
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCommonCore/Public/AppInstallerErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define APPINSTALLER_CLI_ERROR_NO_SOURCES_DEFINED ((HRESULT)0x8A150015)
#define APPINSTALLER_CLI_ERROR_MULTIPLE_APPLICATIONS_FOUND ((HRESULT)0x8A150016)
#define APPINSTALLER_CLI_ERROR_NO_MANIFEST_FOUND ((HRESULT)0x8A150017)
#define APPINSTALLER_CLI_ERROR_EXTENSION_PUBLIC_FAILED ((HRESULT)0x8A150018)
JohnMcPMS marked this conversation as resolved.
Show resolved Hide resolved

namespace AppInstaller
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ namespace AppInstaller::Repository::Microsoft
THROW_HR(APPINSTALLER_CLI_ERROR_SOURCE_DATA_MISSING);
}

std::filesystem::path indexLocation = extension->GetPublicFolderPath();
indexLocation /= s_PreIndexedPackageSourceFactory_IndexFileName;
// To work around an issue with accessing the public folder, we are temporarily
// constructing the location ourself. This was already the case for the non-packaged
// runtime, and we can fix both in the future. The only problem with this is that
// the directory in the extension *must* be Public, rather than one set by the creator.
std::filesystem::path indexLocation = extension->GetPackagePath();
indexLocation /= s_PreIndexedPackageSourceFactory_IndexFilePath;

SQLiteIndex index = SQLiteIndex::Open(indexLocation.u8string(), SQLiteIndex::OpenDisposition::Immutable);

Expand Down