* refactor: use file api for reading data in import * fix: remove unused import Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com> Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> (cherry picked from commit 702e8674f94fde353ac12885f5782ea73ef75b6f) Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
parent
4863ba154e
commit
f0952d0fbb
3 changed files with 7 additions and 4 deletions
1
.github/workflows/ui-tests.yml
vendored
1
.github/workflows/ui-tests.yml
vendored
|
|
@ -121,6 +121,7 @@ jobs:
|
|||
DB: mariadb
|
||||
|
||||
- name: Verify yarn.lock
|
||||
if: ${{ steps.check-build.outputs.build == 'strawberry' }}
|
||||
run: |
|
||||
cd ~/frappe-bench/apps/frappe
|
||||
yarn install --immutable --immutable-cache --check-cache
|
||||
|
|
|
|||
|
|
@ -572,12 +572,15 @@ class ImportFile:
|
|||
|
||||
######
|
||||
|
||||
def read_file(self, file_path):
|
||||
def read_file(self, file_path: str):
|
||||
extn = os.path.splitext(file_path)[1][1:]
|
||||
|
||||
file_content = None
|
||||
with open(file_path, mode="rb") as f:
|
||||
file_content = f.read()
|
||||
|
||||
file_name = frappe.db.get_value("File", {"file_url": file_path})
|
||||
if file_name:
|
||||
file = frappe.get_doc("File", file_name)
|
||||
file_content = file.get_content()
|
||||
|
||||
return file_content, extn
|
||||
|
||||
|
|
|
|||
|
|
@ -422,7 +422,6 @@ class File(Document):
|
|||
return os.path.exists(self.get_full_path())
|
||||
|
||||
def get_content(self) -> bytes:
|
||||
"""Returns [`file_name`, `content`] for given file name `fname`"""
|
||||
if self.is_folder:
|
||||
frappe.throw(_("Cannot get file contents of a Folder"))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue