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

Add PortableIndex for tracking portable files #2459

Merged
merged 22 commits into from
Aug 27, 2022

Conversation

ryfu-msft
Copy link
Contributor

@ryfu-msft ryfu-msft commented Aug 18, 2022

Related to: #140

This PR adds support for a PortableIndex which will be used to track the files/directories/symlinks that are placed down when installing portable(s) from an archive.

Changes:

  • Addition of a base class called SQLiteStorageBase which SQLiteIndex and PortableIndex both inherit from.
  • Addition of a PortableTable and relevant functions for adding, removing, and updating portable file metadata.
  • Addition of an interface to interact with the PortableIndex

Tests:

  • Test verify that the portable index can be created, opened and modified successfully using the interface methods.
Microsoft Reviewers: Open in CodeFlow

@ryfu-msft ryfu-msft requested a review from a team as a code owner August 18, 2022 18:35
@github-actions
Copy link

github-actions bot commented Aug 18, 2022

@check-spelling-bot Report

Unrecognized words, please review:

  • addfile
  • IPortable
  • portableindex
  • removefile
  • updatefile
To accept these unrecognized words as correct, run the following commands

... in a clone of the [email protected]:ryfu-msft/winget-cli.git repository
on the portableDB branch:

update_files() {
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/winget-cli/issues/comments/1219834045" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u

Copy link
Member

@JohnMcPMS JohnMcPMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not looked at portable index 1.0 or portable table 1.0 cpp files yet, but I might not be able to until tomorrow. Wanted to get these comments to you now.

{
SQLite::Builder::StatementBuilder builder;
builder.Select(SQLite::RowIDName).From(s_PortableTable_Table_Name).Where(s_PortableTable_FilePath_Column);
builder.Equals(path.u8string());
Copy link
Contributor

@yao-msft yao-msft Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Equals

Shall we do case insensitive for comparing paths?

Or normalize the input before adding to the table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added extension method "COLLATE NOCASE" to column builder as well as tests to verify that column is case-insensitive.

@ryfu-msft ryfu-msft requested a review from yao-msft August 26, 2022 00:17
@yao-msft
Copy link
Contributor

#include "Microsoft/Schema/ISQLiteIndex.h"

nit: this should be removed as well

Basically the idea is version.h should not depend on specific sqlite index types


Refers to: src/AppInstallerRepositoryCore/Microsoft/Schema/Version.h:5 in d0a2aee. [](commit_id = d0a2aee, deletion_comment = False)

@yao-msft
Copy link
Contributor

#include "1_6/Interface.h"

remove these, version.cpp now should not be aware of specific sqlite index types


Refers to: src/AppInstallerRepositoryCore/Microsoft/Schema/Version.cpp:13 in d0a2aee. [](commit_id = d0a2aee, deletion_comment = False)

Copy link
Contributor

@yao-msft yao-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ghost
Copy link

ghost commented Aug 27, 2022

access for comting

@ryfu-msft ryfu-msft merged commit 1a6ca17 into microsoft:master Aug 27, 2022
@ryfu-msft ryfu-msft deleted the portableDB branch February 29, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants