mirror of
https://github.com/diced/zipline.git
synced 2025-04-04 23:21:17 -05:00
fix: do not include stats in export + other version stuff (#721)
* notFix: Removed the option to only clear db. It'd be a dangerous thing to continue allowing it. * fix: Exclude returning user's uuid from /api/users. * fix: Use a different method of version checking. * fix: Upstream docker images now have an extended commit tag. * fix: Exclude stats from the export. Has caused a lot of memory problems.
This commit is contained in:
parent
478baeca83
commit
61ab5a192b
9 changed files with 47 additions and 46 deletions
|
@ -2,6 +2,8 @@ node_modules/
|
|||
.next/
|
||||
uploads/
|
||||
.git/
|
||||
!.git/refs
|
||||
!.git/HEAD
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
!.yarn/plugins
|
||||
|
|
8
.github/workflows/docker.yml
vendored
8
.github/workflows/docker.yml
vendored
|
@ -13,7 +13,7 @@ on:
|
|||
|
||||
jobs:
|
||||
push:
|
||||
name: Push Image
|
||||
name: Push Commit Image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
|
@ -22,7 +22,7 @@ jobs:
|
|||
- name: Get version
|
||||
id: version
|
||||
run: |
|
||||
echo "zipline_version=$(jq .version package.json -r)" >> $GITHUB_OUTPUT
|
||||
echo "zipline_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
@ -51,8 +51,8 @@ jobs:
|
|||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
ghcr.io/diced/zipline:v3-trunk
|
||||
ghcr.io/diced/zipline:v3-trunk-${{ steps.version.outputs.zipline_version }}
|
||||
ghcr.io/diced/zipline:v3-trunk-${{ steps.version.outputs.zipline_commit }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/zipline:v3-trunk
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/zipline:v3-trunk-${{ steps.version.outputs.zipline_version }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/zipline:v3-trunk-${{ steps.version.outputs.zipline_commit }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
|
|
@ -53,6 +53,9 @@ ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \
|
|||
ZIPLINE_DOCKER_BUILD=true \
|
||||
NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
COPY .git/refs ./.git/refs
|
||||
COPY .git/HEAD ./.git/HEAD
|
||||
|
||||
|
||||
# Copy only the necessary files from the previous stage
|
||||
COPY --from=builder /zipline/dist ./dist
|
||||
|
|
|
@ -316,7 +316,9 @@ export default function Layout({ children, props }) {
|
|||
variant='dot'
|
||||
color={version.data.update ? 'red' : 'primary'}
|
||||
>
|
||||
{version.data.versions.current}
|
||||
{version.data.isUpstream
|
||||
? version.data.versions.current.slice(0, 7)
|
||||
: version.data.versions.current}
|
||||
</Badge>
|
||||
</Tooltip>
|
||||
</Navbar.Section>
|
||||
|
|
|
@ -7,7 +7,7 @@ import { useState } from 'react';
|
|||
|
||||
export default function ClearStorage({ open, setOpen }) {
|
||||
const [check, setCheck] = useState(false);
|
||||
const handleDelete = async (datasource: boolean, orphaned?: boolean) => {
|
||||
const handleDelete = async (orphaned?: boolean) => {
|
||||
showNotification({
|
||||
id: 'clear-uploads',
|
||||
title: 'Clearing...',
|
||||
|
@ -16,7 +16,7 @@ export default function ClearStorage({ open, setOpen }) {
|
|||
autoClose: false,
|
||||
});
|
||||
|
||||
const res = await useFetch('/api/admin/clear', 'POST', { datasource, orphaned });
|
||||
const res = await useFetch('/api/admin/clear', 'POST', { orphaned });
|
||||
|
||||
if (res.error) {
|
||||
updateNotification({
|
||||
|
@ -65,21 +65,13 @@ export default function ClearStorage({ open, setOpen }) {
|
|||
onClick={() => {
|
||||
setOpen(false);
|
||||
openConfirmModal({
|
||||
title: 'Do you want to clear storage too?',
|
||||
labels: { confirm: 'Yes', cancel: check ? 'Ok' : 'No' },
|
||||
children: check && (
|
||||
<Text size='sm' color='gray'>
|
||||
Due to clearing orphaned files, storage clearing will be unavailable.
|
||||
</Text>
|
||||
),
|
||||
confirmProps: { disabled: check },
|
||||
title: 'Are you sure?',
|
||||
confirmProps: { color: 'red' },
|
||||
children: <Text size='sm'>This action is destructive and irreversible.</Text>,
|
||||
labels: { confirm: 'Yes', cancel: 'No' },
|
||||
onConfirm: () => {
|
||||
closeAllModals();
|
||||
handleDelete(true);
|
||||
},
|
||||
onCancel: () => {
|
||||
closeAllModals();
|
||||
handleDelete(false, check);
|
||||
handleDelete(check);
|
||||
},
|
||||
onClose: () => setCheck(false),
|
||||
});
|
||||
|
|
|
@ -8,21 +8,23 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
|
|||
try {
|
||||
const { orphaned } = req.body;
|
||||
if (orphaned) {
|
||||
const files = await prisma.file.findMany({
|
||||
where: {
|
||||
userId: null,
|
||||
},
|
||||
});
|
||||
const { count } = await prisma.file.deleteMany({
|
||||
where: {
|
||||
userId: null,
|
||||
},
|
||||
});
|
||||
for (const file of files) await datasource.delete(file.name);
|
||||
logger.info(`User ${user.username} (${user.id}) cleared the database of ${count} orphaned files`);
|
||||
return res.json({ message: 'cleared storage (orphaned only)' });
|
||||
}
|
||||
const { count } = await prisma.file.deleteMany({});
|
||||
await datasource.clear();
|
||||
logger.info(`User ${user.username} (${user.id}) cleared the database of ${count} files`);
|
||||
|
||||
if (req.body.datasource) {
|
||||
await datasource.clear();
|
||||
logger.info(`User ${user.username} (${user.id}) cleared storage`);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(`User ${user.username} (${user.id}) failed to clear the database or storage`);
|
||||
logger.error(e);
|
||||
|
|
|
@ -283,14 +283,6 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
|
|||
};
|
||||
}
|
||||
|
||||
const stats = await prisma.stats.findMany();
|
||||
for (const stat of stats) {
|
||||
exportData.stats.push({
|
||||
created_at: stat.createdAt.toISOString(),
|
||||
data: stat.data,
|
||||
});
|
||||
}
|
||||
|
||||
exportData.request.user = exportData.user_map[user.id];
|
||||
|
||||
for (const folder of folders) {
|
||||
|
|
|
@ -3,7 +3,10 @@ import { NextApiReq, NextApiRes, withZipline } from 'middleware/withZipline';
|
|||
|
||||
async function handler(_: NextApiReq, res: NextApiRes) {
|
||||
const users = await prisma.user.findMany();
|
||||
for (let i = 0; i !== users.length; ++i) delete users[i].password;
|
||||
for (let i = 0; i !== users.length; ++i) {
|
||||
delete users[i].password;
|
||||
delete users[i].uuid;
|
||||
}
|
||||
|
||||
return res.json(users);
|
||||
}
|
||||
|
|
|
@ -5,24 +5,29 @@ import { NextApiReq, NextApiRes, withZipline } from 'middleware/withZipline';
|
|||
async function handler(_: NextApiReq, res: NextApiRes) {
|
||||
if (!config.website.show_version) return res.forbidden('version hidden');
|
||||
|
||||
const pkg = JSON.parse(await readFile('package.json', 'utf8'));
|
||||
const pRev = await (async function () {
|
||||
try {
|
||||
return await readFile('.git/HEAD', 'utf8');
|
||||
} catch (e) {
|
||||
return JSON.parse(await readFile('package.json', 'utf8')).version;
|
||||
}
|
||||
})();
|
||||
const { groups } = new RegExp(/^ref: (?<ref>(\w+\/?)*)/).exec(pRev) || { groups: null };
|
||||
let rev: string;
|
||||
|
||||
const re = await fetch('https://zipline.diced.sh/api/version?c=' + pkg.version);
|
||||
if (!groups) rev = pRev;
|
||||
else rev = await readFile(`.git/${groups.ref}`, 'utf8');
|
||||
|
||||
const re = await fetch(`https://v3.zipline.diced.sh/api/version?c=?c=${rev}`);
|
||||
const json = await re.json();
|
||||
|
||||
if (!re.ok) return res.badRequest(json.error);
|
||||
let updateToType = 'stable';
|
||||
|
||||
if (json.isUpstream) {
|
||||
updateToType = 'upstream';
|
||||
|
||||
if (json.update?.stable) {
|
||||
updateToType = 'stable';
|
||||
}
|
||||
}
|
||||
if (json.isUpstream) updateToType = 'upstream';
|
||||
|
||||
return res.json({
|
||||
isUpstream: true,
|
||||
update: json.update?.stable || json.update?.upstream,
|
||||
isUpstream: json.isUpstream,
|
||||
update: json.isUpstream ? json.update?.upstream : json.update?.stable,
|
||||
updateToType,
|
||||
versions: {
|
||||
stable: json.git.stable,
|
||||
|
|
Loading…
Add table
Reference in a new issue