Skip to content

Migration does not migrate attachments of issues on a given Gitea instance #152

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

Open
Benjamin-Loison opened this issue Feb 18, 2025 · 216 comments

Comments

@Benjamin-Loison
Copy link
Owner

Benjamin-Loison commented Feb 18, 2025

Description

To migrate a Gitea repository from https://gitea.lemnoslife.com with Issues need on https://gitea.lemnoslife.com/user/settings/applications Select permissions repository and issue Read.

However, as the target issue:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAgCtPFcBBvNjWZeO1ThYoNk50f/Uyau3Am482znzMx3kw
Arz0IO+trzf6KneZoIy88aFrJ33YqSppD7fkspxuAJlZ9uUsgQG8bg129fB4XnHd
0pQBA5kTNrFh1UpYgJ1p2GnkyiMxXmVFVTxQIcuqn2XpjnhlIgRWIqioilvUPQYG
wq6blp7BtOTneEskf7iRVXjB7ReW4hpw7PP39q3tCXKwdjvycgEjuVEStD4qKYcH
yMI8kX2sxUsu+gakHZjGi40kl9zCsJ0pPXIbWKEyHvC/TWs4yYVt31qeEUoMjY2X
VXWBfVVT
=fvvL
-----END PGP MESSAGE-----

shows, the attachments are not imported, while they are important to me, in comparison the initial issue: https://gitea.lemnoslife.com/Benjamin_Loison/Repository_with_an_issue_attachment/issues/1

The attachment URL:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAruKBjTwJtyIzPUtF3lQXWqa7iG1f2JJQynN3qtXVT2ww
Fxr/OlfLQg+5pn3rbPD5pnRLEOfgOsA6Ymgb2rempvT/3FaYChZdyCfteSP8HaIj
0rIB+XutUAbivPAQ/sLG6Kqw1sn3gHhkYBKn9Fsx7zq2l3UtwdLTY2FeQUU6FjWp
2a5HJYoYbkgC5sXBZU31cWRtI091JcJDnSH/ZCYHGTfMVFqN0W35Ru98wDYFikwj
V1ZtAncpdKQB0Q51VPAUcu/CLIQcaFK3Fo8xcPaC6s7To+0A2U40IQGi2n0OXJzm
tuVJNc1VV7z+X5NOmnEGHOsoVKuojpxJ3Xyz08NLTWZKRc6V
=/t/s
-----END PGP MESSAGE-----

returns Not Found

Maybe due to URL /git/ introduction, related to Benjamin_Loison/nginx/issues/5.

Creating a repository directly on the target instance make attachment upload and rendering fine in an issue.
Migrating from the target instance itself does not have the issue. It is because the attachment id already works fine, it keeps the issue comment as it is but not specify the attachments, so works fine.

Gitea Version

Not read.

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Not read.

Database

None

@Benjamin-Loison
Copy link
Owner Author

I sent a message to the Gitea instance owner:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAjNChhMDSUUgvDtXwjb6mh+XppZ9A2kNDEDpbs+zIFWww
2Clejc/XBpLwwbbrD+uJftTqKcmujImIU3NtDeckMvh5jzEQFKx1UtLhjDgPO1mE
0qoB5SSf3j7bhVKIfVnQDq1e8iKftTw9PwLxUDjOhtnAL/3D14XFojkWPLml7ybW
hQTfuHs/6usBHo2hjiHUZxdPTHtK2lUMOXjXjQHiujxdGaDlDLWCwe3/9NEeTVGi
J/0e+1hiwxfj4iIlL5TleS7E3RtXCEu0BN4EQ6eOZ5N7Ii6nol8tSzJjmsu7cRYK
XDc22EoJNM19nOJJxRhGTN2wUF9w7YbipLlpIg==
=dy7Z
-----END PGP MESSAGE-----

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Feb 26, 2025

The setup is made of a nginx redirecting to an Apache. I compared the BookStack nginx configuration with my /etc/nginx/sites-enabled/gitea and it was looking correct.

This setup may be available at:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAnYSwt1yOdSSxKaXWKaOK0+xbPWdX6+FvMfT45wIMPFcw
ipUXYzHSCwiLiwUctfnhCetiZXKBoJzwYNWlGMA+RyHk/41kQICq+HwDNuGZeeNn
0nABZKXmVn0BOzd90q3f7fFFnXyfVoBkw4buZRkrIgarw2Wkq1UndoOIdofKGULs
srvWEJ5PgvtulDPkeZ+eceiPhnmtazXXo+ZTUitflDYeuMmN3BngC8hyQBYzozIX
vqsFvVAy4shcuu1sfewoB5PI
=I5bl
-----END PGP MESSAGE-----

The Stack Overflow answer 25755343 helps with a2enmod/ln -s/ls /etc/apache/mods-{available,enabled}/ getting at Apache level the provided headers and they seem correct. So they seem correctly passed through nginx. The Stack Overflow answer 25714765 is an alternative in PHP as BookStack is PHP made (see BookStack) but may mean to temporarily stop it.

Related to Benjamin_Loison/BookStack/issues/22.

@Benjamin-Loison
Copy link
Owner Author

It is not an issue of domain name gitea.lemnoslife.com being blocked like on Eduroam, see Improve_websites_thanks_to_open_source/issues/494, as the issue presence and body is transmitted.

@Benjamin-Loison
Copy link
Owner Author

Same issue when migrate a repository with an issue attachment from the given Gitea instance to mine.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Feb 26, 2025

find in the Gitea docker does not find any svg or file name mentioning the hash file name c1dd2c05-6be7-41a9-b0b5-2a87b5b5fb4a.

However on OverClock3000:

find /var/lib/gitea/ -name 'c1dd2c05-6be7-41a9-b0b5-2a87b5b5fb4a'
/var/lib/gitea/data/attachments/c/1/c1dd2c05-6be7-41a9-b0b5-2a87b5b5fb4a
Both URLs to the issue attachment:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAMLYCglcmW+3tqhBmiljFEZ29TgyMTwheTbIvNs8nkxQw
oIA/K2MGFrYCYdmdeu1UAsc4vvBaK3CHvulxMema6Ujp6YA6KuL+GEKm/5dqn5jA
0sAHAcTSTKupR5PtyFidlJ2VukOVNneIUVz0SmlSLAgfvK0tK2niJ32wtfb0pVdn
KpGWZGDU5/3pUfRsFwvmhdZ0sCvEPOSWjsgQiu/Zs4mxKFboc4SZDpx+jBhQUwfZ
dS+B63+Aaof4CZPHys6GpEs+QKlHEoMkjMZ2abtpckRHgKXe4tuYkHUaX2lfEMt0
e6QV6QqXd210az+7xKHb6OOdu7fy+v/T8z2uD6VdkTmAKXhrqSODCKBZYll2U/Wp
V2vaQkrc6osE9A==
=GOT7
-----END PGP MESSAGE-----

look correct, note that the file name is identical, either because it is enforced during the migration or because it is a hash of the file content.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Feb 26, 2025

Investigating migration source code may help but is maybe not the most time efficient.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Mar 19, 2025

Maybe I had to some extent this issue on my Gitea instance:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAT6ff7s8CeWkZ6V2+mkyfojBA2gXwdHadlfLA12BFiUow
VIYwmssBCYwam3ywSzntrDmHNJkoQ+wdxBa7AVJ2JFWqs5Dpwd0PhjDZQ54dnuRN
0sAAAZ4nnXlnvpH84/MYttaX8n9s8lTuQLSvGFfHFsqxrtv/GCzbo++NokoNxW0q
QNSvGDPJ7T+YJGK8Hn1cW5jH5rb3AfbnIFQNksE6er1e81OR/6rsY0fTIEP09z7y
IWHzMxuZYi6suzuDMMNQlDg1vNDUXyMvJ60zxra9iTjbHAqajg1r+mQv/56WyhEO
bVf6mHKt37o29cAE7YWuNVbwr4SWYqc1Tzx1GQsnHl/o0ddreHfC57e9FlRZzOUW
QvNW
=Vnmw
-----END PGP MESSAGE-----
Tracked at:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAxlIFHl5SjzuqV6QSIBj0qg95+f9c6h4+BNg+G6gXvRww
zzQs9ckUDyFw/MIofJF0s42TGPK+AncHRXh9FZ+1ICXnOH6elhLELKc1795oAEZu
0qABK6St+VNifc/UaGAlPD66xgsExF7VPTzEV25JY7CFJaPABOBEWDQreZkXjOz3
BJN4xEfDmEYNqBK/mRyKkve0oSGnawB9mfJTaWJg12fA034TURS5wOrjBJ1GZPUS
+fP09lVMghkQcymbDiAImX0u79O+bYfZUcWnngH5TEEF0dsJM5IPOxwyQyACEsa9
WG9c0r8YwJ15xvXXfJBttxta
=E33E
-----END PGP MESSAGE-----

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 7, 2025

The persons:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAG3z+Gtx8+tVITomU0r99KK2HXT81zcf9XFaiHK9kaQQw
89jBwTElGUf5O/69QunO+Pr+mCFwzDadhVhUItWM2CXYqrBxCnZjSnZrxMtFE+ce
0kgB7SuOLi+f93qLdzRNGD/HgeXwUo2kP+SOw7POzsWELKQZrtkG+pxwSwsMW1YG
uLWInVQm1DQRPel815zxFe+WAvoxeyb0SEs=
=mc+x
-----END PGP MESSAGE-----

do not use the concerned Gitea, so do not face this issue.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 7, 2025

Let us wait the domain name migration to .fr, see the message:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdA83NYc7+9e71sfVw7spGPAsgSZZJf1o80eB20UOMIA3gw
U9mgPesW3P3tg2Dzi52b+Z4cy4WW5mPa40kTZExGA0URVw35Pc/Ibzr/Js97WO/k
0qoBMBARyajCWWJVr8QzHNeDvlhPsiWDq1sRKxDKbSsMoYVR+euhSiAPKy7ebMbk
hzbhVeLmXlYZFpOu/FqrOPxzLgf0Urb6nttOcBqzoBgqnt1JufuD5iMc48QbDFyn
rQTAJBDKx+KvaEEi/iYzVHQa2+sLJwhkxaJCtPzGlLgcWKQtZFQm8npQeWQqm0IQ
iWPOvjX3CUadxxU1AuXSVWxZJrGhae5uioGdxw==
=Yna2
-----END PGP MESSAGE-----

Otherwise having Gitea instance log access (at least logs when the issue happen) or even system admin access would help solving this issue.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 7, 2025

Same issue on Codeberg with Benjamin_Loison/Example_to_backup_attachments_of_issues/issues/1.

See the target issue:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAZ4UDxp6KkxD9g75cqJiY07epZsxki68/cHIMZY+urBUw
KSLZhbtXRvbpquSV0hxDde4mK6O8N5QhZlFX85VZBIpsLvxsffCdEVDc3fiPMovH
0pUBKq+RCCeB9O0u9Qq2U+KAjW0pzPMVGXEROOyavj5Do3lvit0JhcdSW53QxXCV
llsrRrDnnqP4mQKFKA9AcxDPlyaX2HQ01C8+K15N573BpzIHGZYu+wJI7jBw5Afd
XYExf9SmTkoaDzNuWRZq3037G1VjS00NO8rzfuYjJByQRvAt6rH9jc+bAIc/nPaW
uFGpgN6+SQ==
=T5Wr
-----END PGP MESSAGE-----

I confirm that migrating from the secret instance to Codeberg, leads to the same issue, see Benjamin_Loison/Repository_with_an_actual_issue_attachment/issues/1.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 7, 2025

Should try between two Gitea instances without the secret one.

If really a pain to setup another one as https://gitea-test.lemnoslife.com on another server, then could ask the person:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAo06OqdFcHkr1aL7L01W1vLSdx09T3hY26EVX+Avx8HQw
C2oJA6nJVq9H0Du1+4tPAsmQRjZAlnsul0exRyy1RSD6Zoa+999B4XeOcaxKqjcw
0oEBXyrHGL/CXr7BLX5GNMDaQ0EutukYmwde+LMdkawE8WGLk5Rlprc7NTiVHDCY
jsEKMLdVwB0PtLpzVqv1zO52zm+3vO2AQKB+MluTk7EEP4KSIxZw/LD5rJwMwHFw
IKdCPssQxXsPIvcQhmwJBCf812TjxVdacoEZjfzrAl1NLdw=
=yq8l
-----END PGP MESSAGE-----

@Benjamin-Loison
Copy link
Owner Author

After the migration I still notice the issue, see the message:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAfSFc3F3I7h/3GfR4IMrqsvm2hWpTtEB7Wb/DaApn1z0w
WwxI7Le1diDSZzMzHUzEjM/gmNqU7E52ZDmbybuK1Ulixlw62xb7viHgxf8IjFKH
0qoBNUZRuPwl5ihpk/9RSYOAhphpL9z00Dntnxou9Y2zNIXXWgGW9+2/NLAegLR7
UQh+6NJrMdjoMZkJytI1w2PIlp+k93vmLQRbfxEKJEZ56mYI0E+FHH/ZEI1DrAuk
6OCQHNs0xa5ir2X9EgpPcFMo8dj+xzMoQFUWIF0ciDgZ+TpEeCbIZd7tpNC91lE8
pCaAHU3vZVJ1/MefvIBS0z5WDkYG5YzKamuQdQ==
=Rffb
-----END PGP MESSAGE-----

@Benjamin-Loison
Copy link
Owner Author

Related to #46.

@Benjamin-Loison
Copy link
Owner Author

Alternatively can make a script to upload attachments if possible.

@Benjamin-Loison
Copy link
Owner Author

https://git.pole-recherche.fr/api/swagger#/issue/issueCreateIssueCommentAttachment

curl -X 'POST' 'https://git.CENSORED.fr/api/v1/repos/Benjamin_Loison/Repository_with_an_issue_attachment/issues/comments/164/assets?name=elysee.svg' -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F '[email protected];type=image/svg+xml'
Output:
{"message":"token is required","url":"https://git.CENSORED.fr/api/swagger"}

@Benjamin-Loison
Copy link
Owner Author

If add -H 'Authorization: token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', then get:
{
    "message": "token does not have at least one of required scope(s), required=[write:issue], token scope=public-only,read:issue",
    "url": "https://git.CENSORED.fr/api/swagger"
}

Source: Authorize

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 11, 2025

Token Name: Import issue comment attachments (https://github.com/Benjamin-Loison/gitea/issues/152)

@Benjamin-Loison
Copy link
Owner Author

Do not proceed by hand as the new instance may be restored to a previous state as the migration is not officially completely finished as far as I understand.

@Benjamin-Loison
Copy link
Owner Author

With the right permissions I now get:
{
    "message": "no matching issue comment found",
    "url": "https://git.CENSORED.fr/api/swagger"
}

https://git.CENSORED.fr/api/v1/repos/Benjamin_Loison/Repository_with_an_issue_attachment/issues/comments returns [].

@Benjamin-Loison
Copy link
Owner Author

https://git.CENSORED.fr/Benjamin_Loison/Repository_with_an_issue_attachment/issues/1#issue-164

well it is an issue and not an issue comment...

@Benjamin-Loison
Copy link
Owner Author

Bash script:
 curl -X 'POST' 'https://git.CENSORED.fr/api/v1/repos/Benjamin_Loison/Repository_with_an_issue_attachment/issues/1/assets?name=elysee.svg' -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F '[email protected];type=image/svg+xml' -H 'Authorization: token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Output:
{
    "id": 13,
    "name": "elysee.svg",
    "size": 20518,
    "download_count": 0,
    "created_at": "2025-04-11T19:26:06Z",
    "uuid": "9e7db2f8-8bbb-408a-ae28-ba2f4a3cffb9",
    "browser_download_url": "https://git.CENSORED.fr/attachments/9e7db2f8-8bbb-408a-ae28-ba2f4a3cffb9"
}

so can't enforce the attachment id. Maybe because can't instance wide enforce it, like an issue comment id. However, correcting as most as possible in the repository is not enough as may have external references that we would like to hold even if the domain name changed.

@Benjamin-Loison
Copy link
Owner Author

While can easily have issue comment id collision, attachment one seems less probable without a voluntary attack if it is not a file hash.

@Benjamin-Loison
Copy link
Owner Author

tree /var/lib/gitea/ seems to show that there already empty folders.

So just passing a .zip to the Gitea instance owner to unzip such that it brings my attachments is a workaround to notably keep the attachment ids. Copy link provides relative path, so it should be fine.

So let us work on generating such a .zip only containing the given repository/ies.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 11, 2025

Note that during the Gitea instance owner time of processing should not add new attachment to old source instance considered repository/ies.

@Benjamin-Loison
Copy link
Owner Author

For generality let us not make a script leveraging running on source Gitea instance, hence having access to /var/lib/gitea/.

@Benjamin-Loison
Copy link
Owner Author

Maybe the number of folders to prefix the hash depends on the number of instance attachments, so should just provide a zip that the instance owner is able to adapt on its instance. If it is variable, then should prevent during adding attachments should pause write access to the instance at least. Maybe the attachments need to be tracked by a database not to be garbage collected or similar but we will figure out if it happens.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 11, 2025

Proceeding this way will lose attachment names but I can be fine with that, at least for a first iteration. Well maybe it is not that acceptable.

@Benjamin-Loison
Copy link
Owner Author

https://codeberg.org/api/swagger#/issue/issueGetComments seems to face the same issue as Gitea, as the following person was wondering:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAsreyM+rAmK9f3wQxLYXWH86hSbozjWpr/5CriauYcT8w
RMQfvZ8mPfc3853juuH8NQWVmRssoK1AzYNk+eJF709GnpvCh+kibk3d+anyV3pg
0kIBVpXSY8te7voWdbQdX+s3aOiHlGMCvkm4acXDyRBT/XY9r7gcOCCIlxfNmGM8
mHOsIjusIGC9tkUQVxCPplBlQLA=
=aTZ+
-----END PGP MESSAGE-----

@Benjamin-Loison
Copy link
Owner Author

Related to Benjamin_Loison/codeberg/issues/3.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 21, 2025

So compared to an attachment shown at least as an issue, not an issue comment, I don't see any difference, so can attach them as if there was no difference if possible:

SELECT * FROM attachment WHERE uuid = '3127a3b4-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
Output:
+-----+--------------------------------------+---------+----------+------------+-------------+------------+--------------+----------------+-------+--------------+
| id  | uuid                                 | repo_id | issue_id | release_id | uploader_id | comment_id | name         | download_count | size  | created_unix |
+-----+--------------------------------------+---------+----------+------------+-------------+------------+--------------+----------------+-------+--------------+
| 628 | 3127a3b4-XXXX-XXXX-XXXX-XXXXXXXXXXXX |     126 |     1588 |          0 |           1 |          0 | CENSORED |             15 | 15040 |   1737117601 |
+-----+--------------------------------------+---------+----------+------------+-------------+------------+--------------+----------------+-------+--------------+
1 row in set (0.001 sec)

@Benjamin-Loison
Copy link
Owner Author

Benjamin_Loison/requests-cache/issues/3 would help.

@Benjamin-Loison
Copy link
Owner Author

comment['html_url'].split('#')[0] could help but let us prefer optimizing than common inefficient code even if it is debatable for such details.

@Benjamin-Loison
Copy link
Owner Author

It is preferable to have the attachment exactly assigned to the issue (comment) it was on, so have to pay attention to unattached attachments but used elsewhere than their upload issue (comments).

@Benjamin-Loison
Copy link
Owner Author

Could use set to optimize.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 24, 2025

Can download attachments as the last exportation step.

@Benjamin-Loison
Copy link
Owner Author

Maybe can use a dictionary with uuid as a key.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 24, 2025

Python script:
array = [
    {
        'a': 42,
    },
]

for element in array:
    element = {
        'b': 43,
    }

print(array)
[{'a': 42}]
However, the Python script:
for element in array:
    element['b'] = 43
[{'a': 42, 'b': 43}]
Python script:
for element in array:
    element |= {
        'b': 43,
    }
[{'a': 42, 'b': 43}]

@Benjamin-Loison
Copy link
Owner Author

For unattached attachments, none of name, size, download_count, created_at can be uniquely determined without administrator access, so as they are quite not that important for an edge case, let us accept loosing them.

Well in fact name looks the most important to me and size may be used to show the attachment size when it is attached on the new Gitea instance, so can guess these informations from the actual attachment despite that it is not attached.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 24, 2025

len(requests.get('https://gitea.lemnoslife.com/Benjamin_Loison/CENSORED/attachments/061aba3a-XXXX-XXXX-XXXX-XXXXXXXXXXXX', cookies = {'i_like_gitea': I_LIKE_GITEA_COOKIE}).content)
11472

So it matches size, see #issuecomment-2816842344.

As it is a PNG my method seems binary resistant.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 24, 2025

print(json.dumps(dict(requests.get('https://gitea.lemnoslife.com/Benjamin_Loison/CENSORED/attachments/061aba3a-XXXX-XXXX-XXXX-XXXXXXXXXXXX', cookies = {'i_like_gitea': I_LIKE_GITEA_COOKIE}).headers), indent = 4))
Output:
{
    "Server": "nginx/1.22.1",
    "Date": "Thu, 24 Apr 2025 13:54:08 GMT",
    "Content-Type": "image/png",
    "Content-Length": "11472",
    "Connection": "keep-alive",
    "Accept-Ranges": "bytes",
    "Access-Control-Expose-Headers": "Content-Disposition",
    "Cache-Control": "private, max-age=300",
    "Content-Disposition": "inline; filename=\"CENSORED.png\"; filename*=UTF-8''CENSORED",
    "Etag": "\"061aba3a-XXXX-XXXX-XXXX-XXXXXXXXXXXX\"",
    "Last-Modified": "Fri, 29 Mar 2024 01:12:01 GMT",
    "No-Gzip-Compression": "1",
    "Set-Cookie": "_csrf=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax",
    "X-Content-Type-Options": "nosniff",
    "X-Frame-Options": "SAMEORIGIN"
}
date -d @1711674721
Fri 29 Mar 02:12:01 CET 2024

so it seems that can also guess the size without downloading the file and get the date which we can leverage quite freely.

@Benjamin-Loison
Copy link
Owner Author

DuckDuckGo search Python requests get file name.

@Benjamin-Loison
Copy link
Owner Author

I doubt having used UTF-8 file names but adding support in the future would be nice.

@Benjamin-Loison
Copy link
Owner Author

The Stack Overflow comment 113814041 helps getting the file name.

@Benjamin-Loison
Copy link
Owner Author

Note that GMT is equivalent to UTC it seems.

@Benjamin-Loison
Copy link
Owner Author

Benjamin-Loison commented Apr 24, 2025

Let us avoid to precise default parameters in the JSON, even for parameters that may have a different values than the default one. So release_id was still not present, but let us not specify download_count if it is unknown for instance, so it will be set to 0.

@Benjamin-Loison
Copy link
Owner Author

Note that the attachment of the issue comment:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdA/3HAppiZn/1HTuvUnNY9E0ZpPdPPd8oZjmwH5lwncAYw
SWFU5L7X6zzT+ZuUuhWykTmZ3J4AZItL0utuioOtyxrc/YXGehT7WeZpLmuDIKCc
0q8BCy5aYuyujSv67cOHr7Jzx3q7NE4WGldAnDTJWtx37XXanaAfZPzCzKrUj5PA
C+IYTHqgCsqobbhiE8Zbv5rvAgdgi4VSdRZI0jlPwFoIIKCkAAIHHCZjD1d2lJJR
IH2oa4JMYdwNh8esyv1x2cFpxeaH6SQRhQN0qExOT3Qk5gwHGdsKH5T4fjkOpxEv
sSd78QOIXXnY4HIFYsQ9EmSYzNvZIQa5NRP3Ap0mVA2R
=T90X
-----END PGP MESSAGE-----

is missing. As this repository was not initially on Codeberg, the issue is not Codeberg silent deletion as in #46.

@Benjamin-Loison
Copy link
Owner Author

Note that the cache can quickly get heavy as it is contains a copy of attachments.

@Benjamin-Loison
Copy link
Owner Author

Benjamin_Loison/mysql/issues/13 would help.

@Benjamin-Loison
Copy link
Owner Author

SELECT id, name from repository WHERE name in ('CENSORED_0', 'CENSORED_1');
Output:
+----+------------+
| id | name       |
+----+------------+
| 89 | CENSORED_0 |
| 88 | CENSORED_1 |
+----+------------+
2 rows in set (0.002 sec)

@Benjamin-Loison
Copy link
Owner Author

DELETE FROM attachment WHERE repo_id IN (88, 89);
Query OK, 161 rows affected (0.130 sec)

JOIN would make it not interactive.

@Benjamin-Loison
Copy link
Owner Author

Should ensure that there is no attachment already in the target to correctly test but the aim is also to verify exhaustiveness of listing attachments at import, I suspect that deleting the repository is not perfect, removing all attachments would be preferable.

@Benjamin-Loison
Copy link
Owner Author

cp -R /mnt/git/Gitea/gitea/gitea/{attachments,24_04_25_18_29}/
find /mnt/git/Gitea/gitea/gitea/attachments/ -type f -delete

just copying folder architecture would be more efficient.

@Benjamin-Loison
Copy link
Owner Author

Note that specifying issue comment id is not possible most of the time as it is incremental.

@Benjamin-Loison
Copy link
Owner Author

Benjamin_Loison/bash/issues/31 would help.

@Benjamin-Loison
Copy link
Owner Author

The migration for more than 50 issue comments and attachments on the final instance seems successful.

@Benjamin-Loison
Copy link
Owner Author

On the target instance I have verified that it works fine on multiple repositories, an issue, an issue comment and that a not attached attachment was now correctly migrated by being attached.

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

No branches or pull requests

1 participant