Aves_mio0.88/folders_hybrid.md
2026-10-03 12:51:15 +02:00

217 lines
4.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Perfetto Fabio — **suddividere gli hybrid in device, user e common è non solo possibile, ma è la scelta MIGLIORE** per ottenere:
- controllo totale
- zero ricalcoli inutili
- zero ambiguità
- zero conflitti tra locale e remoto
- una UI pulita senza “@”
E soprattutto: **ti permette di modellare esattamente la semantica che vuoi**.
Ti costruisco ora la **struttura definitiva**, già pronta per essere usata in Aves, con i tre tipi di hybrid che vuoi.
---
# 🎯 OBIETTIVO
Ogni cartella può essere:
- **Locale pura**
- **Remota pura**
- **Hybrid** → ma con tre varianti:
- **Hybrid-Device** (locale + remoto stesso device)
- **Hybrid-User** (locale + remoto stesso user)
- **Hybrid-Common** (locale + remoto “common”)
E tutto questo **senza usare @ nel nome visuale**, ma solo come logica interna.
---
# 🟩 MODELLO DEFINITIVO DELLA TABELLA `folders`
Eccolo, completo e pulito:
```sql
CREATE TABLE IF NOT EXISTS folders (
id INTEGER PRIMARY KEY AUTOINCREMENT,
-- percorso canonico
path TEXT NOT NULL, -- locale: '/storage/...', remoto: 'DCIM', ibrido: '/storage/...'
-- identificazione remota
user TEXT, -- 'fabio', 'common', 'device123'
device_id TEXT, -- per distinguere device diversi dello stesso user
-- flags
is_remote INTEGER NOT NULL DEFAULT 0, -- 0=locale, 1000=remoto
hybrid_type INTEGER NOT NULL DEFAULT 0, -- 0=none, 1=device, 2=user, 3=common
-- tipo album (Aves + estensioni)
album_type INTEGER NOT NULL DEFAULT 0, -- 0=regular,1=app,2=special,3=vault,4=remote,5=hybrid
-- ordinamento globale
priority INTEGER NOT NULL DEFAULT 0,
-- nome visuale (senza @)
display_name TEXT
);
CREATE INDEX IF NOT EXISTS idx_folders_path ON folders(path);
CREATE INDEX IF NOT EXISTS idx_folders_is_remote ON folders(is_remote);
CREATE INDEX IF NOT EXISTS idx_folders_priority ON folders(priority);
CREATE INDEX IF NOT EXISTS idx_folders_hybrid ON folders(hybrid_type);
```
---
# 🟦 COME FUNZIONA LA LOGICA DEI TRE TIPI DI HYBRID
## 1️⃣ **Hybrid-Device**
Locale + remoto dello stesso device.
Esempio:
- locale: `/storage/emulated/0/DCIM/Camera`
- remoto: `DCIM/Camera` con `device_id = pixel7`
Tabella:
```
is_remote = 1000
hybrid_type = 1
user = NULL
device_id = 'pixel7'
```
---
## 2️⃣ **Hybrid-User**
Locale + remoto dello stesso user (ma device diverso).
Esempio:
- locale: `/storage/emulated/0/DCIM/Camera`
- remoto: `DCIM/Camera` con `user = fabio`
Tabella:
```
is_remote = 1000
hybrid_type = 2
user = 'fabio'
device_id = NULL
```
---
## 3️⃣ **Hybrid-Common**
Locale + remoto “common” (cartella condivisa tra device/user).
Esempio:
- locale: `/storage/emulated/0/Shared`
- remoto: `Shared` con `user = common`
Tabella:
```
is_remote = 1000
hybrid_type = 3
user = 'common'
device_id = NULL
```
---
# 🟧 COME SI LEGGE `path` (senza @)
Tu hai detto:
> la visualizzazione del nome deve essere sempre senza @ o @user
Perfetto.
Quindi:
- `path` contiene il percorso “pulito”
- `user` e `device_id` contengono l’identità
- `hybrid_type` dice come interpretarlo
👉 **La UI mostra sempre `display_name` = basename(path)**
👉 **La logica interna usa user/device/common**
---
# 🟩 COME SI POPOLA LA TABELLA (regole chiare)
### ✔ Locale puro
```
is_remote = 0
hybrid_type = 0
user = NULL
device_id = NULL
```
### ✔ Remoto puro
```
is_remote = 1000
hybrid_type = 0
user = 'fabio' | 'common' | 'device123'
device_id = 'pixel7' (se serve)
```
### ✔ Hybrid-Device
```
is_remote = 1000
hybrid_type = 1
device_id = 'pixel7'
```
### ✔ Hybrid-User
```
is_remote = 1000
hybrid_type = 2
user = 'fabio'
```
### ✔ Hybrid-Common
```
is_remote = 1000
hybrid_type = 3
user = 'common'
```
---
# 🟦 MANCANO I GRUPPI DI AVES?
Tu hai chiesto:
> mancano i raggruppamenti che aves già fa e la sua indicizzazione dentro i gruppi. Sarebbe bene inserirli?
Risposta: **SÌ, assolutamente.**
Aves raggruppa gli album in:
- Special (Camera, Download, Screenshots)
- App
- Regular
- Vault
E tu devi aggiungere:
- Remote
- Hybrid
👉 Questo è esattamente il campo `album_type`.
---
# 🟩 PROSSIMO STEP (scegli tu)
Ora che abbiamo la tabella perfetta, possiamo procedere con:
- Popolare la tabella dai remoti
- Popolare la tabella dai locali
- Patch AlbumSource per usare la tabella folders
- Patch CollectionSource per ignorare i remoti
Dimmi quale vuoi fare come prossimo passo.