Skip to content

Commit

Permalink
timeline: allow de-dup with AUID (close #1112)
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <[email protected]>
  • Loading branch information
pulsejet committed Apr 3, 2024
1 parent d8ce7a8 commit 1918535
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [Unreleased]

- **Feature**: Add option to de-duplicate identical files ([#1112](https://github.com/pulsejet/memories/issues/1112)).

## [v7.1.0] - 2024-04-01

- **Notice**: This release significantly overhauls the core querying infrastructure for better performance. If you run into any regressions (including performance), please [file a bug report](https://github.com/pulsejet/memories/issues)
Expand Down
1 change: 1 addition & 0 deletions lib/Db/TimelineQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TimelineQuery
'm.w', 'm.h', 'm.liveid',
'm.isvideo', 'm.video_duration',
'f.etag', 'f.name AS basename',
'f.size', 'm.epoch', // auid
'mimetypes.mimetype',
];

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/TimelineQueryNativeX.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait TimelineQueryNativeX
public function transformNativeQuery(IQueryBuilder &$query, bool $aggregate): void
{
if (!$aggregate) {
$query->addSelect('m.epoch', 'f.size', 'm.buid');
$query->addSelect('m.buid');
}
}
}
12 changes: 12 additions & 0 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
>
{{ t('memories', 'Stack RAW files with same name') }}
</NcCheckboxRadioSwitch>

<NcCheckboxRadioSwitch
:checked.sync="config.dedup_identical"
@update:checked="updateDedupIdentical"
type="switch"
>
{{ t('memories', 'De-duplicate identical files') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>

<NcAppSettingsSection id="viewer-settings" :name="names.viewer">
Expand Down Expand Up @@ -314,6 +322,10 @@ export default defineComponent({
await this.updateSetting('stack_raw_files', 'stackRawFiles');
},
async updateDedupIdentical() {
await this.updateSetting('dedup_identical', 'dedupIdentical');
},
// Viewer settings
async updateHighResCond(val: IConfig['high_res_cond']) {
this.config.high_res_cond = val;
Expand Down
7 changes: 7 additions & 0 deletions src/components/Timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1071,13 +1071,20 @@ export default defineComponent({
// Set of basenames without extension
const res1: IPhoto[] = [];
const toStack = new Map<string, IPhoto[]>();
const auids = new Set<string>();
// First pass -- remove hidden and prepare
for (const photo of data) {
// Skip hidden files
if (photo.ishidden) continue;
if (photo.basename?.startsWith('.')) continue;
// Skip identical duplicates
if (this.config.dedup_identical && photo.auid) {
if (auids.has(photo.auid)) continue;
auids.add(photo.auid);
}
// Add to first pass result
res1.push(photo);
Expand Down
1 change: 1 addition & 0 deletions src/services/static-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class StaticConfig {
timeline_path: '_unknown_',
enable_top_memories: true,
stack_raw_files: true,
dedup_identical: false,

// viewer settings
high_res_cond_default: 'zoom',
Expand Down
1 change: 1 addition & 0 deletions src/typings/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ declare module '@typings' {
timeline_path: string;
enable_top_memories: boolean;
stack_raw_files: boolean;
dedup_identical: boolean;

// viewer settings
high_res_cond_default: HighResCond;
Expand Down

0 comments on commit 1918535

Please sign in to comment.