Skip to content
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

Fix copy network #186

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

GolrovKirill
Copy link
Contributor

No description provided.

@@ -489,7 +489,26 @@ def copy_network():
n = Network(author_id=user.id, guid=str(u))
n.network = net.network
n.title = net.title + str(" - копия")
n.preview_uri = net.preview_uri

new_picture_blob_uri = os.urandom(16).hex() + ".png"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты скопировал способ генерации picture_blob_uri.
Тогда лучше выделить его в метод/функцию и применить в обоих местах, чтобы небыло копирования кода.

try:
open("static/images/preview/" + new_picture_blob_uri, "wb").write(
copy_picture_blob
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это очень странный способ скопировать файл.
Используй https://docs.python.org/3/library/shutil.html

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

Successfully merging this pull request may close these issues.

2 participants