Merge branch 'main' into eng-1828-migration-to-new-cloud-api-system

This commit is contained in:
Arnab Chakraborty 2024-08-17 00:37:56 +03:00
commit 9366122c00
17 changed files with 1352 additions and 851 deletions

View File

@ -42,15 +42,22 @@ runs:
path: crates/prisma/src/**/*.rs
- name: Generate Prisma client
working-directory: core
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }}
shell: bash
run: |
set -euxo pipefail
cargo prisma generate
npx -y prisma generate --schema core/prisma/schema.prisma
if ! {
[ -f crates/prisma/src/prisma/mod.rs ] && \
[ -f crates/prisma/src/prisma_sync/mod.rs ]
}; then
echo "Prisma generation failed" >&2
exit 1
fi
# Check if a new migration should be created due to changes in the schema
cargo prisma migrate dev -n test --create-only --skip-generate
npx -y prisma migrate dev --schema core/prisma/schema.prisma -n test --create-only --skip-generate
_new_migrations="$(
git ls-files --others --exclude-standard \
| { grep '^prisma/migrations/' || true; } \
@ -62,7 +69,7 @@ runs:
echo "::error file=core/prisma/schema.prisma,title=Missing migration::New migration should be generated due to changes in prisma schema"
case "$GITHUB_REF" in
"refs/heads/main" | "refs/heads/gh-readonly-queue/main/"* | "refs/tags/"*)
# Fail action if we are on main or a release tag, to avoid releasing an app with a broken db
# Fail action if we are on main, merge queue or a release tag, to avoid releasing the app with a broken db
exit 1
;;
esac

View File

@ -172,16 +172,19 @@ jobs:
with:
filters: |
changes:
- 'apps/cli/*/**'
- 'apps/desktop/crates/*/**'
- 'apps/desktop/src-tauri/*/**'
- 'apps/mobile/crates/*/**'
- 'apps/server/*/**'
- 'apps/cli/**'
- 'apps/desktop/crates/**'
- 'apps/desktop/src-tauri/**'
- 'apps/mobile/crates/**'
- 'apps/server/**'
- 'core/**'
- 'crates/*/**'
- 'extensions/*/**'
- 'crates/**'
- 'extensions/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/ci.yml'
- '.github/actions/setup-rust/**'
- '.github/actions/setup-system/**'
- name: Setup Rust and Prisma
if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'
@ -242,17 +245,19 @@ jobs:
changes:
- ${{ runner.os == 'Windows' && 'scripts/setup.ps1' || 'scripts/setup.sh' }}
- 'scripts/preprep.mjs'
- 'apps/cli/*/**'
- 'apps/desktop/crates/*/**'
- 'apps/desktop/src-tauri/*/**'
- 'apps/mobile/crates/*/**'
- 'apps/server/*/**'
- 'apps/cli/**'
- 'apps/desktop/crates/**'
- 'apps/desktop/src-tauri/**'
- 'apps/mobile/crates/**'
- 'apps/server/**'
- 'core/**'
- 'crates/*/**'
- 'extensions/*/**'
- 'crates/**'
- 'extensions/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/ci.yml'
- '.github/actions/setup-rust/**'
- '.github/actions/setup-system/**'
- name: Setup System and Rust
if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'

View File

@ -138,7 +138,7 @@ jobs:
ios:
name: iOS
runs-on: macos-12
runs-on: macos-14
steps:
- name: Checkout repository
uses: actions/checkout@v4
@ -200,7 +200,7 @@ jobs:
uses: futureware-tech/simulator-action@v3
with:
model: 'iPhone 14'
os_version: 16
os_version: 17.4
erase_before_boot: false
- name: Run Tests

23
Cargo.lock generated
View File

@ -7122,7 +7122,7 @@ dependencies = [
name = "prisma-cli"
version = "0.1.0"
dependencies = [
"prisma-client-rust-cli",
"prisma-client-rust-generator",
"sd-sync-generator",
]
@ -7160,26 +7160,6 @@ dependencies = [
"uuid",
]
[[package]]
name = "prisma-client-rust-cli"
version = "0.6.8"
source = "git+https://github.com/brendonovich/prisma-client-rust?rev=4f9ef9d38c#4f9ef9d38ca732162accff72b2eb684d2f120bab"
dependencies = [
"directories 4.0.1",
"flate2",
"http 0.2.12",
"prisma-client-rust-generator",
"proc-macro2",
"quote",
"regex",
"reqwest 0.11.27",
"serde",
"serde_json",
"serde_path_to_error",
"syn 1.0.109",
"thiserror",
]
[[package]]
name = "prisma-client-rust-generator"
version = "0.6.8"
@ -8787,6 +8767,7 @@ dependencies = [
"tracing-test",
"trash",
"uuid",
"windows 0.58.0",
]
[[package]]

View File

@ -539,6 +539,10 @@ fabric.properties
# Expo
web-build/
android/
ios/
!modules/sd-core/android/
!modules/sd-core/ios/
# Native
*.orig.*

View File

@ -23,7 +23,7 @@
"@hookform/resolvers": "^3.1.0",
"@oscartbeaumont-sd/rspc-client": "=0.0.0-main-dc31e5b2",
"@oscartbeaumont-sd/rspc-react": "=0.0.0-main-dc31e5b2",
"@react-native-async-storage/async-storage": "~1.22.3",
"@react-native-async-storage/async-storage": "~1.23.1",
"@react-native-masked-view/masked-view": "^0.3.1",
"@react-navigation/bottom-tabs": "^6.5.19",
"@react-navigation/drawer": "^6.6.14",
@ -31,42 +31,42 @@
"@react-navigation/native-stack": "^6.9.25",
"@sd/assets": "workspace:*",
"@sd/client": "workspace:*",
"@shopify/flash-list": "1.6.3",
"@shopify/flash-list": "1.6.4",
"@tanstack/react-query": "^4.36.1",
"babel-preset-solid": "^1.8.9",
"class-variance-authority": "^0.7.0",
"dayjs": "^1.11.10",
"event-target-polyfill": "^0.0.4",
"expo": "~50.0.11",
"expo-av": "^13.10.5",
"expo-blur": "^12.9.2",
"expo-build-properties": "~0.11.1",
"expo-haptics": "~12.8.1",
"expo-image": "^1.10.6",
"expo-linking": "~6.2.2",
"expo-media-library": "~15.9.1",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"expo": "~51.0.28",
"expo-av": "^14.0.6",
"expo-blur": "^13.0.2",
"expo-build-properties": "~0.12.5",
"expo-haptics": "~13.0.1",
"expo-image": "^1.12.13",
"expo-linking": "~6.3.1",
"expo-media-library": "~16.0.4",
"expo-splash-screen": "~0.27.5",
"expo-status-bar": "~1.12.1",
"intl": "^1.2.5",
"lottie-react-native": "6.7.0",
"manage-external-storage": "^0.1.3",
"metro-react-native-babel-transformer": "^0.77.0",
"moti": "^0.28.1",
"moti": "^0.29.0",
"phosphor-react-native": "^2.0.0",
"react": "^18.2.0",
"react-hook-form": "^7.47.0",
"react-native": "0.73.4",
"react-native": "0.74.5",
"react-native-circular-progress": "^1.3.9",
"react-native-device-info": "^10.13.1",
"react-native-document-picker": "^9.0.1",
"react-native-file-viewer": "^2.1.5",
"react-native-gesture-handler": "~2.14.1",
"react-native-gesture-handler": "~2.16.2",
"react-native-linear-gradient": "^2.8.3",
"react-native-popup-menu": "^0.16.1",
"react-native-reanimated": "~3.6.3",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
"react-native-svg": "14.1.0",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "~3.31.1",
"react-native-svg": "15.2.0",
"react-native-toast-message": "^2.2.0",
"react-native-wheel-color-picker": "^1.2.0",
"rive-react-native": "^6.2.3",
@ -82,10 +82,10 @@
"@babel/core": "^7.24.0",
"@rnx-kit/metro-config": "^1.3.15",
"@sd/config": "workspace:*",
"@types/react": "^18.2.67",
"@types/react": "^18.2.79",
"babel-plugin-module-resolver": "^5.0.0",
"eslint-plugin-react-native": "^4.1.0",
"react-native-svg-transformer": "^1.3.0",
"typescript": "^5.4.2"
"typescript": "^5.3.3"
}
}

View File

@ -128,7 +128,8 @@ trash = "5.1"
trash = "5.1"
[target.'cfg(target_os = "windows")'.dependencies]
trash = "5.1"
trash = "5.1"
windows = { features = ["Win32_Storage_FileSystem"], version = "0.58" }
[target.'cfg(target_os = "ios")'.dependencies]
icrate = { version = "0.1.2", features = [

View File

@ -103,9 +103,10 @@ pub fn path_is_hidden(path: impl AsRef<Path>, metadata: &Metadata) -> bool {
}
#[cfg(target_family = "windows")]
fn get_inode_windows(path: &str) -> Result<u64, std::io::Error> {
use std::{ffi::OsStr, os::windows::ffi::OsStrExt, ptr::null_mut};
fn get_inode_windows<P: AsRef<Path>>(path: P) -> Result<u64, std::io::Error> {
use std::ptr::null_mut;
use windows::{
core::HSTRING,
Win32::Foundation::HANDLE,
Win32::Storage::FileSystem::{
CreateFileW, GetFileInformationByHandle, BY_HANDLE_FILE_INFORMATION,
@ -115,33 +116,27 @@ fn get_inode_windows(path: &str) -> Result<u64, std::io::Error> {
let handle = unsafe {
CreateFileW(
PCWSTR::from(&HSTRING::from(path)),
&HSTRING::from(path.as_ref()),
0,
FILE_SHARE_READ,
null_mut(),
None,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
HANDLE(0),
HANDLE(null_mut()),
)
};
if handle.is_invalid() {
return Err(std::io::Error::last_os_error());
}
}?;
let mut file_info = BY_HANDLE_FILE_INFORMATION::default();
let result = unsafe { GetFileInformationByHandle(handle, &mut file_info) };
unsafe { GetFileInformationByHandle(handle, &mut file_info) }?;
if result.as_bool() {
Ok(file_info.nFileIndexLow as u64 | ((file_info.nFileIndexHigh as u64) << 32))
} else {
Err(std::io::Error::last_os_error())
}
Ok(file_info.nFileIndexLow as u64 | ((file_info.nFileIndexHigh as u64) << 32))
}
impl FilePathMetadata {
pub fn from_path(path: impl AsRef<Path>, metadata: &Metadata) -> Result<Self, FilePathError> {
let path = path.as_ref();
pub fn from_path(
path: impl AsRef<Path> + Copy,
metadata: &Metadata,
) -> Result<Self, FilePathError> {
let inode = {
#[cfg(target_family = "unix")]
{
@ -151,8 +146,8 @@ impl FilePathMetadata {
#[cfg(target_family = "windows")]
{
tokio::task::block_in_place(|| {
get_inode_windows(path).map_err(|e| FileIOError::from((path, e)))
})?;
get_inode_windows(path.as_ref()).map_err(|e| FileIOError::from((path, e)))
})?
}
};
@ -416,15 +411,9 @@ pub async fn get_inode_from_path(path: impl AsRef<Path> + Send) -> Result<u64, F
#[cfg(target_family = "windows")]
{
use winapi_util::{file::information, Handle};
let info = tokio::task::block_in_place(|| {
Handle::from_path_any(path.as_ref())
.and_then(|ref handle| information(handle))
.map_err(|e| FileIOError::from((path, e)))
})?;
Ok(info.file_index())
Ok(tokio::task::block_in_place(|| {
get_inode_windows(path.as_ref()).map_err(|e| FileIOError::from((path, e)))
})?)
}
}

View File

@ -21,7 +21,7 @@ pub(super) struct InnerMetadata {
impl InnerMetadata {
pub fn new(
path: impl AsRef<Path>,
path: impl AsRef<Path> + Copy,
metadata: &Metadata,
) -> Result<Self, indexer::NonCriticalIndexerError> {
let FilePathMetadata {

View File

@ -30,12 +30,21 @@ use uuid::Uuid;
use super::LocationManagerError;
mod android;
mod ios;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "ios")]
mod ios;
#[cfg(target_os = "android")]
mod android;
mod utils;
use utils::reject_event;

View File

@ -259,9 +259,8 @@ impl SpacedriveLocationMetadataFile {
#[cfg(target_os = "windows")]
{
let FILE_ATTRIBUTE_HIDDEN = 0x00000002; // Windows file attribute byte indicating hidden file
use std::os::windows::fs::OpenOptionsExt;
file_options.attributes(FILE_ATTRIBUTE_HIDDEN);
use windows::Win32::Storage::FileSystem::FILE_ATTRIBUTE_HIDDEN;
file_options.attributes(FILE_ATTRIBUTE_HIDDEN.0);
}
let metadata_contents = serde_json::to_vec(&self.metadata)

View File

@ -11,7 +11,7 @@ repository.workspace = true
sd-sync-generator = { path = "../sync-generator" }
# Specific prisma-cli dependencies
[dependencies.prisma-client-rust-cli]
[dependencies.prisma-client-rust-generator]
default-features = false
features = ["migrations", "specta", "sqlite", "sqlite-create-many"]
git = "https://github.com/brendonovich/prisma-client-rust"

View File

@ -1,3 +1,3 @@
fn main() {
prisma_client_rust_cli::run();
prisma_client_rust_generator::run();
}

View File

@ -7,8 +7,8 @@
"postprep": "pnpm codegen",
"build": "turbo run build",
"landing-web": "turbo run dev --parallel --filter=@sd/landing --filter=@sd/web",
"gen:migrations": "cd core && cargo prisma migrate dev",
"gen:prisma": "cd core && cargo prisma generate",
"gen:migrations": "pnpm prisma migrate dev --schema core/prisma/schema.prisma",
"gen:prisma": "pnpm prisma generate --schema core/prisma/schema.prisma",
"format": "prettier --write .",
"desktop": "pnpm --filter @sd/desktop --",
"tauri": "pnpm desktop tauri",
@ -21,7 +21,6 @@
"assets": "pnpm --filter @sd/assets -- ",
"client": "pnpm --filter @sd/client -- ",
"storybook": "pnpm --filter @sd/storybook -- ",
"prisma": "cd core && cargo prisma",
"dev:web": "pnpm --filter @sd/web dev:web",
"dev:desktop": "pnpm run --filter @sd/desktop tauri dev",
"bootstrap:desktop": "cargo clean && ./scripts/setup.sh && pnpm i && pnpm prep && pnpm tauri dev",
@ -59,6 +58,7 @@
"cspell": "^8.6.0",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.6",
"prisma": "^5.18.0",
"turbo": "^1.12.5",
"turbo-ignore": "^1.12.5",
"typescript": "^5.4.2",

1985
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

9
scripts/list-dup-deps.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
_root="$(CDPATH='' cd "$(dirname "$0")" && pwd -P)"
grep -Po '^\s+"[\w-]+\s+\d(\.\d+)*[^"]*"' "${_root}/../Cargo.lock" \
| xargs printf '%s\n' \
| sort -u -k 1b,2V

View File

@ -18,12 +18,12 @@
"trailingComma": "es5"
},
"dependencies": {
"@iarna/toml": "^2.2.5",
"archive-wasm": "^1.6.1",
"@iarna/toml": "^3.0.0",
"archive-wasm": "^1.7.0",
"mustache": "^4.2.0",
"os-proxy-config": "^1.1.1",
"semver": "^7.6.0",
"undici": "^6.9.0"
"semver": "^7.6.3",
"undici": "^6.19.7"
},
"devDependencies": {
"@babel/core": "^7.24.0",