Skip to content

Commit 6c2406a

Browse files
committed
finish
1 parent aa985d7 commit 6c2406a

19 files changed

+1126
-542
lines changed
Binary file not shown.

Assignment1/client_ui.py

Lines changed: 329 additions & 7 deletions
Large diffs are not rendered by default.

Assignment1/database.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ def list_peers_for_file(self, fname: str) -> List[Dict[str, object]]:
8787
rows = cur.fetchall()
8888
return list(rows)
8989

90+
def list_all_shared_files(self) -> List[Dict[str, object]]:
91+
query = """
92+
SELECT
93+
fname,
94+
COUNT(*) AS peer_count,
95+
MAX(file_size) AS file_size,
96+
MAX(last_modified) AS last_modified
97+
FROM file_index
98+
GROUP BY fname
99+
ORDER BY fname
100+
"""
101+
with self._connect() as conn, conn.cursor(cursor_factory=RealDictCursor) as cur:
102+
cur.execute(query)
103+
rows = cur.fetchall()
104+
return list(rows)
105+
90106
def get_entry(self, fname: str, hostname: str, ip: str, port: int) -> Optional[Dict[str, object]]:
91107
query = """
92108
SELECT fname, hostname, ip, port, lname, file_size, last_modified

Assignment1/log.json

Whitespace-only changes.

Assignment1/old/client_old.py

Lines changed: 0 additions & 235 deletions
This file was deleted.

Assignment1/old/protocol_old.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)